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

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
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) 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 target.consoleModel.addMessage(consoleMessage);
245 return; 240 return;
246 } 241 }
247 242
248 var breakpointLocations = this._removeBreakpoints(uiSourceCode); 243 var breakpointLocations = this._removeBreakpoints(uiSourceCode);
249 this._restoreBreakpoints(uiSourceCode, breakpointLocations); 244 this._restoreBreakpoints(uiSourceCode, breakpointLocations);
250 245
251 this._runScript(scriptId, executionContext); 246 this._runScript(scriptId, executionContext, evaluationUrl);
252 } 247 }
253 }, 248 },
254 249
255 /** 250 /**
256 * @param {!DebuggerAgent.ScriptId} scriptId 251 * @param {!DebuggerAgent.ScriptId} scriptId
257 * @param {!WebInspector.ExecutionContext} executionContext 252 * @param {!WebInspector.ExecutionContext} executionContext
258 */ 253 */
259 _runScript: function(scriptId, executionContext) 254 _runScript: function(scriptId, executionContext, sourceURL)
260 { 255 {
261 var target = executionContext.target(); 256 var target = executionContext.target();
262 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));
263 258
264 /** 259 /**
265 * @param {!WebInspector.Target} target 260 * @param {!WebInspector.Target} target
266 * @param {?string} error 261 * @param {?string} error
267 * @param {?RuntimeAgent.RemoteObject} result 262 * @param {?RuntimeAgent.RemoteObject} result
268 * @param {boolean=} wasThrown 263 * @param {?DebuggerAgent.ExceptionDetails=} exceptionDetails
269 * @this {WebInspector.ScriptSnippetModel} 264 * @this {WebInspector.ScriptSnippetModel}
270 */ 265 */
271 function runCallback(target, error, result, wasThrown) 266 function runCallback(target, error, result, exceptionDetails)
272 { 267 {
273 if (error) { 268 if (error) {
274 console.error(error); 269 console.error(error);
275 return; 270 return;
276 } 271 }
277 272
278 this._printRunScriptResult(target, result, wasThrown); 273 var wasThrown = !!exceptionDetails;
aandrey 2014/06/05 10:22:56 remove this var?
274 if (!wasThrown)
275 this._printRunScriptResult(target, result, sourceURL);
276 else
277 this._printRunOrCompileScriptResultFailure(target, exceptionDeta ils, sourceURL);
279 } 278 }
280 }, 279 },
281 280
282 /** 281 /**
283 * @param {!WebInspector.Target} target 282 * @param {!WebInspector.Target} target
284 * @param {?RuntimeAgent.RemoteObject} result 283 * @param {?RuntimeAgent.RemoteObject} result
285 * @param {boolean=} wasThrown 284 * @param {?string=} sourceURL
286 */ 285 */
287 _printRunScriptResult: function(target, result, wasThrown) 286 _printRunScriptResult: function(target, result, sourceURL)
288 { 287 {
289 var level = (wasThrown ? WebInspector.ConsoleMessage.MessageLevel.Error : WebInspector.ConsoleMessage.MessageLevel.Log); 288 var consoleMessage = new WebInspector.ConsoleMessage(
290 var message = new WebInspector.ConsoleMessage(target, 289 target,
291 WebInspector.ConsoleMessage.MessageSource.JS, 290 WebInspector.ConsoleMessage.MessageSource.JS,
292 level, 291 WebInspector.ConsoleMessage.MessageLevel.Log,
293 "", 292 "",
294 undefined, 293 undefined,
294 sourceURL,
295 undefined,
295 undefined, 296 undefined,
296 undefined, 297 undefined,
297 undefined, 298 [result],
298 undefined, 299 undefined);
299 [result]); 300 target.consoleModel.addMessage(consoleMessage);
300 target.consoleModel.addMessage(message);
301 }, 301 },
302 302
303 /** 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 /**
304 * @param {!WebInspector.DebuggerModel.Location} rawLocation 326 * @param {!WebInspector.DebuggerModel.Location} rawLocation
305 * @return {?WebInspector.UILocation} 327 * @return {?WebInspector.UILocation}
306 */ 328 */
307 _rawLocationToUILocation: function(rawLocation) 329 _rawLocationToUILocation: function(rawLocation)
308 { 330 {
309 var uiSourceCode = this._uiSourceCodeForScriptId[rawLocation.scriptId]; 331 var uiSourceCode = this._uiSourceCodeForScriptId[rawLocation.scriptId];
310 if (!uiSourceCode) 332 if (!uiSourceCode)
311 return null; 333 return null;
312 return uiSourceCode.uiLocation(rawLocation.lineNumber, rawLocation.colum nNumber || 0); 334 return uiSourceCode.uiLocation(rawLocation.lineNumber, rawLocation.colum nNumber || 0);
313 }, 335 },
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
628 this._model.deleteScriptSnippet(path); 650 this._model.deleteScriptSnippet(path);
629 }, 651 },
630 652
631 __proto__: WebInspector.ContentProviderBasedProjectDelegate.prototype 653 __proto__: WebInspector.ContentProviderBasedProjectDelegate.prototype
632 } 654 }
633 655
634 /** 656 /**
635 * @type {!WebInspector.ScriptSnippetModel} 657 * @type {!WebInspector.ScriptSnippetModel}
636 */ 658 */
637 WebInspector.scriptSnippetModel; 659 WebInspector.scriptSnippetModel;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698