Minor improvements and fixes

This commit is contained in:
apemanzilla
2017-12-01 11:05:57 -05:00
parent 062b76a351
commit 6167dfa82f
3 changed files with 30 additions and 13 deletions

View File

@@ -67,4 +67,23 @@ export class ErrorMapper {
this.cache[stack] = outStack;
return outStack;
}
public static wrapLoop(loop: () => void): () => void {
return () => {
try {
loop();
} catch (e) {
if (e instanceof Error) {
if ("sim" in Game.rooms) {
console.log(`<span style='color:red'>Source maps don't work in the simulator - displaying original error<br>${_.escape(e.stack)}</span>`)
} else {
console.log(`<span style='color:red'>${_.escape(this.sourceMappedStackTrace(e))}</span>`);
}
} else {
// can't handle it
throw e;
}
}
}
}
}