on master help sign in
Report some runtime errors on screen
c8d2734Evan Czaplicki
runtime/Init.js+9−1
@@ -96,7 +96,14 @@ function init(display, container, module, moduleToReplace) {
96 return newElm;
96 return newElm;
97 }
97 }
98
98
99− var Module = module(elm);
99+ var Module = {};
100+ var reportAnyErrors = function() {};
101+ try {
102+ Module = module(elm);
103+ } catch(e) {
104+ Module.main = Elm.Text(elm).text('<code>' + e.message + '</code>');
105+ reportAnyErrors = function() { throw e; }
106+ }
100 inputs = ElmRuntime.filterDeadInputs(inputs);
107 inputs = ElmRuntime.filterDeadInputs(inputs);
101 filterListeners(inputs, listeners);
108 filterListeners(inputs, listeners);
102 if (display !== ElmRuntime.Display.NONE) {
109 if (display !== ElmRuntime.Display.NONE) {
@@ -112,6 +119,7 @@ function init(display, container, module, moduleToReplace) {
112 }
119 }
113 }
120 }
114
121
122+ reportAnyErrors();
115 return { send:send, recv:recv, swap:swap };
123 return { send:send, recv:recv, swap:swap };
116};
124};
117
125