Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(223)

Side by Side Diff: Source/devtools/front_end/sdk/ScriptSnippetModel.js

Issue 290633009: DevTools: Show detailed information for exceptions during snippet execution. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 var evaluationUrl = this._evaluationSourceURL(uiSourceCode); 214 var evaluationUrl = this._evaluationSourceURL(uiSourceCode);
215 var expression = uiSourceCode.workingCopy(); 215 var expression = uiSourceCode.workingCopy();
216 216
217 WebInspector.console.show(); 217 WebInspector.console.show();
218 var target = executionContext.target(); 218 var target = executionContext.target();
219 target.debuggerAgent().compileScript(expression, evaluationUrl, executio nContext.id, compileCallback.bind(this, target)); 219 target.debuggerAgent().compileScript(expression, evaluationUrl, executio nContext.id, compileCallback.bind(this, target));
220 220
221 /** 221 /**
222 * @param {!WebInspector.Target} target 222 * @param {!WebInspector.Target} target
223 * @param {?string} error 223 * @param {?string} error
224 * @param {string=} scriptId 224 * @param {!DebuggerAgent.ScriptId=} scriptId
225 * @param {string=} syntaxErrorMessage 225 * @param {?DebuggerAgent.ExceptionDetails=} exceptionDetails
226 * @this {WebInspector.ScriptSnippetModel} 226 * @this {WebInspector.ScriptSnippetModel}
227 */ 227 */
228 function compileCallback(target, error, scriptId, syntaxErrorMessage, li neNumber, columnNumber) 228 function compileCallback(target, error, scriptId, exceptionDetails)
229 { 229 {
230 if (!uiSourceCode || uiSourceCode._evaluationIndex !== evaluationInd ex) 230 if (!uiSourceCode || uiSourceCode._evaluationIndex !== evaluationInd ex)
231 return; 231 return;
232 232
233 if (error) { 233 if (error) {
234 console.error(error); 234 console.error(error);
235 return; 235 return;
236 } 236 }
237 237
238 if (!scriptId) { 238 if (!scriptId) {
239 var consoleMessage = new WebInspector.ConsoleMessage( 239 this._printRunOrCompileScriptResultFailure(target, exceptionDeta ils, evaluationUrl);
240 target,
241 WebInspector.ConsoleMessage.MessageSource.JS,
242 WebInspector.ConsoleMessage.MessageLevel.Error,
243 syntaxErrorMessage || "",
244 undefined,
245 evaluationUrl,
246 lineNumber,
247 columnNumber);
248 target.consoleModel.addMessage(consoleMessage);
249 return; 240 return;
250 } 241 }
251 242
252 var breakpointLocations = this._removeBreakpoints(uiSourceCode); 243 var breakpointLocations = this._removeBreakpoints(uiSourceCode);
253 this._restoreBreakpoints(uiSourceCode, breakpointLocations); 244 this._restoreBreakpoints(uiSourceCode, breakpointLocations);
254 245
255 this._runScript(scriptId, executionContext, evaluationUrl); 246 this._runScript(scriptId, executionContext, evaluationUrl);
256 } 247 }
257 }, 248 },
258 249
259 /** 250 /**
260 * @param {!DebuggerAgent.ScriptId} scriptId 251 * @param {!DebuggerAgent.ScriptId} scriptId
261 * @param {!WebInspector.ExecutionContext} executionContext 252 * @param {!WebInspector.ExecutionContext} executionContext
262 */ 253 */
263 _runScript: function(scriptId, executionContext, sourceURL) 254 _runScript: function(scriptId, executionContext, sourceURL)
264 { 255 {
265 console.error(executionContext);
266 var target = executionContext.target(); 256 var target = executionContext.target();
267 target.debuggerAgent().runScript(scriptId, executionContext.id, "console ", false, runCallback.bind(this, target)); 257 target.debuggerAgent().runScript(scriptId, executionContext.id, "console ", false, runCallback.bind(this, target));
268 258
269 /** 259 /**
270 * @param {!WebInspector.Target} target 260 * @param {!WebInspector.Target} target
271 * @param {?string} error 261 * @param {?string} error
272 * @param {?RuntimeAgent.RemoteObject} result 262 * @param {?RuntimeAgent.RemoteObject} result
273 * @param {boolean=} wasThrown 263 * @param {?DebuggerAgent.ExceptionDetails=} exceptionDetails
274 * @this {WebInspector.ScriptSnippetModel} 264 * @this {WebInspector.ScriptSnippetModel}
275 */ 265 */
276 function runCallback(target, error, result, wasThrown, lineNumber, colum nNumber) 266 function runCallback(target, error, result, exceptionDetails)
277 { 267 {
278 if (error) { 268 if (error) {
279 console.error(error); 269 console.error(error);
280 return; 270 return;
281 } 271 }
282 272
283 this._printRunScriptResult(target, result, wasThrown, sourceURL, lin eNumber, columnNumber); 273 var wasThrown = !!exceptionDetails;
274 if (!wasThrown)
275 this._printRunScriptResult(target, result, sourceURL);
276 else
277 this._printRunOrCompileScriptResultFailure(target, exceptionDeta ils, sourceURL);
284 } 278 }
285 }, 279 },
286 280
287 /** 281 /**
288 * @param {!WebInspector.Target} target 282 * @param {!WebInspector.Target} target
289 * @param {?RuntimeAgent.RemoteObject} result 283 * @param {?RuntimeAgent.RemoteObject} result
290 * @param {boolean=} wasThrown 284 * @param {?string=} sourceURL
291 */ 285 */
292 _printRunScriptResult: function(target, result, wasThrown, sourceURL, lineNu mber, columnNumber) 286 _printRunScriptResult: function(target, result, sourceURL)
293 { 287 {
294 var level = (wasThrown ? WebInspector.ConsoleMessage.MessageLevel.Error : WebInspector.ConsoleMessage.MessageLevel.Log); 288 var consoleMessage = new WebInspector.ConsoleMessage(
295 var message = new WebInspector.ConsoleMessage(target, 289 target,
296 WebInspector.ConsoleMessage.MessageSource.JS, 290 WebInspector.ConsoleMessage.MessageSource.JS,
297 level, 291 WebInspector.ConsoleMessage.MessageLevel.Log,
298 (wasThrown ? result.description : ""), 292 "",
299 undefined, 293 undefined,
300 (wasThrown ? sourceURL : undefined), 294 sourceURL,
301 (wasThrown ? lineNumber : undefined),
302 (wasThrown ? columnNumber : undefined),
303 undefined, 295 undefined,
304 (wasThrown ? undefined : [result])); 296 undefined,
305 target.consoleModel.addMessage(message); 297 undefined,
298 [result],
299 undefined);
300 target.consoleModel.addMessage(consoleMessage);
306 }, 301 },
307 302
308 /** 303 /**
304 * @param {!WebInspector.Target} target
305 * @param {?DebuggerAgent.ExceptionDetails=} exceptionDetails
306 * @param {?string=} sourceURL
307 */
308 _printRunOrCompileScriptResultFailure: function(target, exceptionDetails, so urceURL)
309 {
310 var consoleMessage = new WebInspector.ConsoleMessage(
311 target,
312 exceptionDetails.source,
313 WebInspector.ConsoleMessage.MessageLevel.Error,
314 exceptionDetails.text,
315 undefined,
316 sourceURL,
317 exceptionDetails.line,
318 exceptionDetails.column,
319 undefined,
320 undefined,
321 exceptionDetails.stackTrace);
322 target.consoleModel.addMessage(consoleMessage);
323 },
324
325 /**
309 * @param {!WebInspector.DebuggerModel.Location} rawLocation 326 * @param {!WebInspector.DebuggerModel.Location} rawLocation
310 * @return {?WebInspector.UILocation} 327 * @return {?WebInspector.UILocation}
311 */ 328 */
312 _rawLocationToUILocation: function(rawLocation) 329 _rawLocationToUILocation: function(rawLocation)
313 { 330 {
314 var uiSourceCode = this._uiSourceCodeForScriptId[rawLocation.scriptId]; 331 var uiSourceCode = this._uiSourceCodeForScriptId[rawLocation.scriptId];
315 if (!uiSourceCode) 332 if (!uiSourceCode)
316 return null; 333 return null;
317 return uiSourceCode.uiLocation(rawLocation.lineNumber, rawLocation.colum nNumber || 0); 334 return uiSourceCode.uiLocation(rawLocation.lineNumber, rawLocation.colum nNumber || 0);
318 }, 335 },
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
633 this._model.deleteScriptSnippet(path); 650 this._model.deleteScriptSnippet(path);
634 }, 651 },
635 652
636 __proto__: WebInspector.ContentProviderBasedProjectDelegate.prototype 653 __proto__: WebInspector.ContentProviderBasedProjectDelegate.prototype
637 } 654 }
638 655
639 /** 656 /**
640 * @type {!WebInspector.ScriptSnippetModel} 657 * @type {!WebInspector.ScriptSnippetModel}
641 */ 658 */
642 WebInspector.scriptSnippetModel; 659 WebInspector.scriptSnippetModel;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698