diff --git a/app/assets/javascripts/workers/worker_world.js b/app/assets/javascripts/workers/worker_world.js index 9b6264173..a1c4baf0f 100644 --- a/app/assets/javascripts/workers/worker_world.js +++ b/app/assets/javascripts/workers/worker_world.js @@ -266,7 +266,6 @@ self.enableFlowOnThangSpell = function (thangID, spellID, userCodeMap) { self.setupDebugWorldToRunUntilFrame = function (args) { self.debugPostedErrors = {}; self.debugt0 = new Date(); - self.debugPostedErrors = false; self.logsLogged = 0; var stringifiedUserCodeMap = JSON.stringify(args.userCodeMap); @@ -324,7 +323,6 @@ self.debugAbort = function () { self.runWorld = function runWorld(args) { self.postedErrors = {}; self.t0 = new Date(); - self.postedErrors = false; self.logsLogged = 0; try { @@ -394,6 +392,7 @@ self.onWorldError = function onWorldError(error) { } else { console.log("Non-UserCodeError:", error.toString() + "\n" + error.stack || error.stackTrace); + self.postMessage({type: 'non-user-code-problem', problem: {message: error.toString()}}); } /* We don't actually have the recoverable property any more; hmm if(!error.recoverable) { diff --git a/app/lib/Angel.coffee b/app/lib/Angel.coffee index 2014e6471..fbdb252db 100644 --- a/app/lib/Angel.coffee +++ b/app/lib/Angel.coffee @@ -71,6 +71,14 @@ module.exports = class Angel extends CocoClass when 'user-code-problem' Backbone.Mediator.publish 'god:user-code-problem', problem: event.data.problem + # We have to abort like an infinite loop if we see one of these; they're not really recoverable + when 'non-user-code-problem' + Backbone.Mediator.publish 'god:non-user-code-problem', problem: event.data.problem + if @shared.firstWorld + @infinitelyLooped() # For now, this should do roughly the right thing if it happens during load. + else + @fireWorker() + # Either the world finished simulating successfully, or we abort the worker. when 'new-world' @beholdWorld event.data.serialized, event.data.goalStates diff --git a/app/views/play/level/tome/spell_view.coffee b/app/views/play/level/tome/spell_view.coffee index f42ecb121..04851959e 100644 --- a/app/views/play/level/tome/spell_view.coffee +++ b/app/views/play/level/tome/spell_view.coffee @@ -35,6 +35,7 @@ module.exports = class SpellView extends View 'surface:coordinate-selected': 'onCoordinateSelected' 'god:new-world-created': 'onNewWorld' 'god:user-code-problem': 'onUserCodeProblem' + 'god:non-user-code-problem': 'onNonUserCodeProblem' 'tome:manual-cast': 'onManualCast' 'tome:reload-code': 'onCodeReload' 'tome:spell-changed': 'onSpellChanged' @@ -441,9 +442,18 @@ module.exports = class SpellView extends View @lastUpdatedAetherSpellThang = null # force a refresh without a re-transpile @updateAether false, false + onNonUserCodeProblem: (e) -> + return unless @spellThang + problem = @spellThang.aether.createUserCodeProblem type: 'runtime', kind: 'Unhandled', message: "Unhandled error: #{e.problem.message}" + @spellThang.aether.addProblem problem + @spellThang.castAether?.addProblem problem + @lastUpdatedAetherSpellThang = null # force a refresh without a re-transpile + @updateAether false, false # TODO: doesn't work, error doesn't display + onInfiniteLoop: (e) -> return unless @spellThang @spellThang.aether.addProblem e.problem + @spellThang.castAether?.addProblem e.problem @lastUpdatedAetherSpellThang = null # force a refresh without a re-transpile @updateAether false, false