Merge branch 'master' into production

This commit is contained in:
Nick Winter 2014-05-26 19:13:16 -07:00
commit b21f14f0b5
3 changed files with 19 additions and 2 deletions

View file

@ -266,7 +266,6 @@ self.enableFlowOnThangSpell = function (thangID, spellID, userCodeMap) {
self.setupDebugWorldToRunUntilFrame = function (args) { self.setupDebugWorldToRunUntilFrame = function (args) {
self.debugPostedErrors = {}; self.debugPostedErrors = {};
self.debugt0 = new Date(); self.debugt0 = new Date();
self.debugPostedErrors = false;
self.logsLogged = 0; self.logsLogged = 0;
var stringifiedUserCodeMap = JSON.stringify(args.userCodeMap); var stringifiedUserCodeMap = JSON.stringify(args.userCodeMap);
@ -324,7 +323,6 @@ self.debugAbort = function () {
self.runWorld = function runWorld(args) { self.runWorld = function runWorld(args) {
self.postedErrors = {}; self.postedErrors = {};
self.t0 = new Date(); self.t0 = new Date();
self.postedErrors = false;
self.logsLogged = 0; self.logsLogged = 0;
try { try {
@ -394,6 +392,7 @@ self.onWorldError = function onWorldError(error) {
} }
else { else {
console.log("Non-UserCodeError:", error.toString() + "\n" + error.stack || error.stackTrace); 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 /* We don't actually have the recoverable property any more; hmm
if(!error.recoverable) { if(!error.recoverable) {

View file

@ -71,6 +71,14 @@ module.exports = class Angel extends CocoClass
when 'user-code-problem' when 'user-code-problem'
Backbone.Mediator.publish 'god:user-code-problem', problem: event.data.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. # Either the world finished simulating successfully, or we abort the worker.
when 'new-world' when 'new-world'
@beholdWorld event.data.serialized, event.data.goalStates @beholdWorld event.data.serialized, event.data.goalStates

View file

@ -35,6 +35,7 @@ module.exports = class SpellView extends View
'surface:coordinate-selected': 'onCoordinateSelected' 'surface:coordinate-selected': 'onCoordinateSelected'
'god:new-world-created': 'onNewWorld' 'god:new-world-created': 'onNewWorld'
'god:user-code-problem': 'onUserCodeProblem' 'god:user-code-problem': 'onUserCodeProblem'
'god:non-user-code-problem': 'onNonUserCodeProblem'
'tome:manual-cast': 'onManualCast' 'tome:manual-cast': 'onManualCast'
'tome:reload-code': 'onCodeReload' 'tome:reload-code': 'onCodeReload'
'tome:spell-changed': 'onSpellChanged' 'tome:spell-changed': 'onSpellChanged'
@ -441,9 +442,18 @@ module.exports = class SpellView extends View
@lastUpdatedAetherSpellThang = null # force a refresh without a re-transpile @lastUpdatedAetherSpellThang = null # force a refresh without a re-transpile
@updateAether false, false @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) -> onInfiniteLoop: (e) ->
return unless @spellThang return unless @spellThang
@spellThang.aether.addProblem e.problem @spellThang.aether.addProblem e.problem
@spellThang.castAether?.addProblem e.problem
@lastUpdatedAetherSpellThang = null # force a refresh without a re-transpile @lastUpdatedAetherSpellThang = null # force a refresh without a re-transpile
@updateAether false, false @updateAether false, false