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

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, 6 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
« no previous file with comments | « Source/core/inspector/InspectorDebuggerAgent.cpp ('k') | Source/devtools/protocol.json » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 var mapping = this._mappingForTarget.get(target); 238 var mapping = this._mappingForTarget.get(target);
239 mapping._setEvaluationIndex(evaluationIndex, uiSourceCode); 239 mapping._setEvaluationIndex(evaluationIndex, uiSourceCode);
240 var evaluationUrl = mapping._evaluationSourceURL(uiSourceCode); 240 var evaluationUrl = mapping._evaluationSourceURL(uiSourceCode);
241 var expression = uiSourceCode.workingCopy(); 241 var expression = uiSourceCode.workingCopy();
242 target.consoleModel.show(); 242 target.consoleModel.show();
243 target.debuggerAgent().compileScript(expression, evaluationUrl, executio nContext.id, compileCallback.bind(this, target)); 243 target.debuggerAgent().compileScript(expression, evaluationUrl, executio nContext.id, compileCallback.bind(this, target));
244 244
245 /** 245 /**
246 * @param {!WebInspector.Target} target 246 * @param {!WebInspector.Target} target
247 * @param {?string} error 247 * @param {?string} error
248 * @param {string=} scriptId 248 * @param {!DebuggerAgent.ScriptId=} scriptId
249 * @param {string=} syntaxErrorMessage 249 * @param {?DebuggerAgent.ExceptionDetails=} exceptionDetails
250 * @this {WebInspector.ScriptSnippetModel} 250 * @this {WebInspector.ScriptSnippetModel}
251 */ 251 */
252 function compileCallback(target, error, scriptId, syntaxErrorMessage) 252 function compileCallback(target, error, scriptId, exceptionDetails)
253 { 253 {
254 if (!uiSourceCode || this._mappingForTarget.get(target).evaluationIn dex(uiSourceCode) !== evaluationIndex) 254 if (!uiSourceCode || this._mappingForTarget.get(target).evaluationIn dex(uiSourceCode) !== evaluationIndex)
255 return; 255 return;
256 256
257 if (error) { 257 if (error) {
258 console.error(error); 258 console.error(error);
259 return; 259 return;
260 } 260 }
261 261
262 if (!scriptId) { 262 if (!scriptId) {
263 var consoleMessage = new WebInspector.ConsoleMessage( 263 this._printRunOrCompileScriptResultFailure(target, exceptionDeta ils, evaluationUrl);
264 target,
265 WebInspector.ConsoleMessage.MessageSource.JS,
266 WebInspector.ConsoleMessage.MessageLevel.Error,
267 syntaxErrorMessage || "");
268 target.consoleModel.addMessage(consoleMessage);
269 return; 264 return;
270 } 265 }
271 266
272 var breakpointLocations = this._removeBreakpoints(uiSourceCode); 267 var breakpointLocations = this._removeBreakpoints(uiSourceCode);
273 this._restoreBreakpoints(uiSourceCode, breakpointLocations); 268 this._restoreBreakpoints(uiSourceCode, breakpointLocations);
274 269
275 this._runScript(scriptId, executionContext); 270 this._runScript(scriptId, executionContext, evaluationUrl);
276 } 271 }
277 }, 272 },
278 273
279 /** 274 /**
280 * @param {!DebuggerAgent.ScriptId} scriptId 275 * @param {!DebuggerAgent.ScriptId} scriptId
281 * @param {!WebInspector.ExecutionContext} executionContext 276 * @param {!WebInspector.ExecutionContext} executionContext
277 * @param {?string=} sourceURL
282 */ 278 */
283 _runScript: function(scriptId, executionContext) 279 _runScript: function(scriptId, executionContext, sourceURL)
284 { 280 {
285 var target = executionContext.target(); 281 var target = executionContext.target();
286 target.debuggerAgent().runScript(scriptId, executionContext.id, "console ", false, runCallback.bind(this, target)); 282 target.debuggerAgent().runScript(scriptId, executionContext.id, "console ", false, runCallback.bind(this, target));
287 283
288 /** 284 /**
289 * @param {!WebInspector.Target} target 285 * @param {!WebInspector.Target} target
290 * @param {?string} error 286 * @param {?string} error
291 * @param {?RuntimeAgent.RemoteObject} result 287 * @param {?RuntimeAgent.RemoteObject} result
292 * @param {boolean=} wasThrown 288 * @param {?DebuggerAgent.ExceptionDetails=} exceptionDetails
293 * @this {WebInspector.ScriptSnippetModel} 289 * @this {WebInspector.ScriptSnippetModel}
294 */ 290 */
295 function runCallback(target, error, result, wasThrown) 291 function runCallback(target, error, result, exceptionDetails)
296 { 292 {
297 if (error) { 293 if (error) {
298 console.error(error); 294 console.error(error);
299 return; 295 return;
300 } 296 }
301 297
302 this._printRunScriptResult(target, result, wasThrown); 298 if (!exceptionDetails)
299 this._printRunScriptResult(target, result, sourceURL);
300 else
301 this._printRunOrCompileScriptResultFailure(target, exceptionDeta ils, sourceURL);
303 } 302 }
304 }, 303 },
305 304
306 /** 305 /**
307 * @param {!WebInspector.Target} target 306 * @param {!WebInspector.Target} target
308 * @param {?RuntimeAgent.RemoteObject} result 307 * @param {?RuntimeAgent.RemoteObject} result
309 * @param {boolean=} wasThrown 308 * @param {?string=} sourceURL
310 */ 309 */
311 _printRunScriptResult: function(target, result, wasThrown) 310 _printRunScriptResult: function(target, result, sourceURL)
312 { 311 {
313 var level = (wasThrown ? WebInspector.ConsoleMessage.MessageLevel.Error : WebInspector.ConsoleMessage.MessageLevel.Log); 312 var consoleMessage = new WebInspector.ConsoleMessage(
314 var message = new WebInspector.ConsoleMessage(target, 313 target,
315 WebInspector.ConsoleMessage.MessageSource.JS, 314 WebInspector.ConsoleMessage.MessageSource.JS,
316 level, 315 WebInspector.ConsoleMessage.MessageLevel.Log,
317 "", 316 "",
318 undefined, 317 undefined,
318 sourceURL,
319 undefined,
319 undefined, 320 undefined,
320 undefined, 321 undefined,
321 undefined, 322 [result],
322 undefined, 323 undefined);
323 [result]); 324 target.consoleModel.addMessage(consoleMessage);
324 target.consoleModel.addMessage(message);
325 }, 325 },
326 326
327 /** 327 /**
328 * @param {!WebInspector.Target} target
329 * @param {?DebuggerAgent.ExceptionDetails=} exceptionDetails
330 * @param {?string=} sourceURL
331 */
332 _printRunOrCompileScriptResultFailure: function(target, exceptionDetails, so urceURL)
333 {
334 var consoleMessage = new WebInspector.ConsoleMessage(
335 target,
336 exceptionDetails.source,
337 WebInspector.ConsoleMessage.MessageLevel.Error,
338 exceptionDetails.text,
339 undefined,
340 sourceURL,
341 exceptionDetails.line,
342 exceptionDetails.column,
343 undefined,
344 undefined,
345 exceptionDetails.stackTrace);
aandrey 2014/07/19 13:15:59 We also need to pass Console.AsyncStackTrace with
346 target.consoleModel.addMessage(consoleMessage);
347 },
348
349 /**
328 * @param {!WebInspector.UISourceCode} uiSourceCode 350 * @param {!WebInspector.UISourceCode} uiSourceCode
329 * @return {!Array.<!{breakpoint: !WebInspector.BreakpointManager.Breakpoint , uiLocation: !WebInspector.UILocation}>} 351 * @return {!Array.<!{breakpoint: !WebInspector.BreakpointManager.Breakpoint , uiLocation: !WebInspector.UILocation}>}
330 */ 352 */
331 _removeBreakpoints: function(uiSourceCode) 353 _removeBreakpoints: function(uiSourceCode)
332 { 354 {
333 var breakpointLocations = WebInspector.breakpointManager.breakpointLocat ionsForUISourceCode(uiSourceCode); 355 var breakpointLocations = WebInspector.breakpointManager.breakpointLocat ionsForUISourceCode(uiSourceCode);
334 for (var i = 0; i < breakpointLocations.length; ++i) 356 for (var i = 0; i < breakpointLocations.length; ++i)
335 breakpointLocations[i].breakpoint.remove(); 357 breakpointLocations[i].breakpoint.remove();
336 return breakpointLocations; 358 return breakpointLocations;
337 }, 359 },
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 this._model.deleteScriptSnippet(path); 685 this._model.deleteScriptSnippet(path);
664 }, 686 },
665 687
666 __proto__: WebInspector.ContentProviderBasedProjectDelegate.prototype 688 __proto__: WebInspector.ContentProviderBasedProjectDelegate.prototype
667 } 689 }
668 690
669 /** 691 /**
670 * @type {!WebInspector.ScriptSnippetModel} 692 * @type {!WebInspector.ScriptSnippetModel}
671 */ 693 */
672 WebInspector.scriptSnippetModel; 694 WebInspector.scriptSnippetModel;
OLDNEW
« no previous file with comments | « Source/core/inspector/InspectorDebuggerAgent.cpp ('k') | Source/devtools/protocol.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698