Skip to content
This repository was archived by the owner on Oct 2, 2018. It is now read-only.

Commit 9bc37a9

Browse files
committed
Notify editor parent on error or console.log()
1 parent 105eb88 commit 9bc37a9

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

modules/editor/scripts/editor.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@ var mainClosure = function() {
2828
throw new Error("origin did not match");
2929
}
3030

31+
// Send message on error or console.log()
32+
window.onerror = function(a,b,c){
33+
parentMessageProxy.postMessage({command: "error", details: [a,b,c]});
34+
};
35+
console.log = function(msg){
36+
parentMessageProxy.postMessage({command: "log", details: msg});
37+
};
38+
3139
// initialize modules/register handlers
3240
// night mode
3341
initNight(doc, parentMessageProxy);

scripts/firetext.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -868,6 +868,14 @@ function editorCommunication(callback) {
868868
editorMessageProxy.registerMessageHandler(function(e) {
869869
callback();
870870
}, "init-success", true);
871+
872+
// Handle errors and logs
873+
editorMessageProxy.registerMessageHandler(function(e) {
874+
console.log(e.data.details);
875+
}, "error", true);
876+
editorMessageProxy.registerMessageHandler(function(e) {
877+
console.log(e.data.details);
878+
}, "log", true);
871879

872880
editorMessageProxy.registerMessageHandler(function(e) {
873881
tempText = e.data.html;

0 commit comments

Comments
 (0)