This commit is contained in:
Cassie Tarakajian 2018-11-20 18:00:54 -05:00
parent d5f2380c31
commit ef98190e25
2 changed files with 9 additions and 6 deletions

View file

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

View file

@ -31,8 +31,11 @@ export const hijackConsoleErrorsScript = (offs) => {
data = msg + ' (' + fileInfo[1] + ': line ' + fileInfo[0] + ')'; data = msg + ' (' + fileInfo[1] + ': line ' + fileInfo[0] + ')';
} }
window.parent.postMessage([{ window.parent.postMessage([{
method: 'error', log: [{
arguments: data, method: 'error',
data: [data],
id: Date.now().toString()
}],
source: fileInfo[1] source: fileInfo[1]
}], '*'); }], '*');
return false; return false;
@ -58,8 +61,8 @@ export const getAllScriptOffsets = (htmlFile) => {
} else { } else {
endFilenameInd = htmlFile.indexOf('.js', ind + startTag.length + 3); endFilenameInd = htmlFile.indexOf('.js', ind + startTag.length + 3);
filename = htmlFile.substring(ind + startTag.length, endFilenameInd); filename = htmlFile.substring(ind + startTag.length, endFilenameInd);
// the length of hijackConsoleErrorsScript is 33 lines // the length of hijackConsoleErrorsScript is 37 lines
lineOffset = htmlFile.substring(0, ind).split('\n').length + 33; lineOffset = htmlFile.substring(0, ind).split('\n').length + 37;
offs.push([lineOffset, filename]); offs.push([lineOffset, filename]);
lastInd = ind + 1; lastInd = ind + 1;
} }