fix console.error crash (#532)

This commit is contained in:
Mr.tang 2018-02-08 16:40:21 -06:00 committed by Cassie Tarakajian
parent 6faf52f61e
commit 193b15e074

View file

@ -187,9 +187,11 @@ class Editor extends React.Component {
if (this.props.runtimeErrorWarningVisible) { if (this.props.runtimeErrorWarningVisible) {
this.props.consoleEvents.forEach((consoleEvent) => { this.props.consoleEvents.forEach((consoleEvent) => {
if (consoleEvent.method === 'error') { if (consoleEvent.method === 'error') {
const n = consoleEvent.arguments.replace(')', '').split(' '); if (consoleEvent.arguments.indexOf(')') > -1) {
const lineNumber = parseInt(n[n.length - 1], 10) - 1; const n = consoleEvent.arguments.replace(')', '').split(' ');
this._cm.addLineClass(lineNumber, 'background', 'line-runtime-error'); const lineNumber = parseInt(n[n.length - 1], 10) - 1;
this._cm.addLineClass(lineNumber, 'background', 'line-runtime-error');
}
} }
}); });
} }