mirror of
https://github.com/smogon/pokemon-showdown-client.git
synced 2026-05-09 04:23:01 -05:00
Improve stacks for exceptions in battles
This commit is contained in:
parent
6698d649f6
commit
cc2aac7bb9
14
js/battle.js
14
js/battle.js
|
|
@ -6023,12 +6023,16 @@ var Battle = (function () {
|
|||
this.runMajor(args, kwargs, preempt);
|
||||
}
|
||||
} catch (e) {
|
||||
this.log('<div class="chat">Error parsing: ' + Tools.escapeHTML(str) + '</div>', preempt);
|
||||
this.log('<div class="chat">Error parsing: ' + Tools.escapeHTML(str) + ' (' + Tools.escapeHTML('' + e) + ')</div>', preempt);
|
||||
if (e.stack) {
|
||||
var stack = '' + e.stack;
|
||||
this.log('<div class="chat" style="white-space:pre-wrap">' + Tools.escapeHTML(stack) + '</div>', preempt);
|
||||
} else {
|
||||
this.log('<div class="chat">Error: ' + Tools.escapeHTML('' + e) + '</div>', preempt);
|
||||
var stack = Tools.escapeHTML('' + e.stack).split('\n');
|
||||
for (var i = 0; i < stack.length; i++) {
|
||||
if (/\brun\b/.test(stack[i])) {
|
||||
stack.length = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
this.log('<div class="chat">' + stack.join('<br>') + '</div>', preempt);
|
||||
}
|
||||
if (this.errorCallback) this.errorCallback(this);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user