@@ -96,7 +96,14 @@ function init(display, container, module, moduleToReplace) {
9696 return newElm;
9797 }
9898
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+ }
100107 inputs = ElmRuntime.filterDeadInputs(inputs);
101108 filterListeners(inputs, listeners);
102109 if (display !== ElmRuntime.Display.NONE) {
@@ -112,6 +119,7 @@ function init(display, container, module, moduleToReplace) {
112119 }
113120 }
114121
122+ reportAnyErrors();
115123 return { send:send, recv:recv, swap:swap };
116124};
117125