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

Side by Side Diff: Source/core/inspector/InjectedScriptSource.js

Issue 369333002: DevTools: Added error message when the command is invoked from the console with exception (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@add-evaluate-exception-details
Patch Set: Created 6 years, 5 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) 2007 Apple Inc. All rights reserved. 2 * Copyright (C) 2007 Apple Inc. All rights reserved.
3 * Copyright (C) 2013 Google Inc. All rights reserved. 3 * Copyright (C) 2013 Google Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after
610 try { 610 try {
611 var objectGroup = this._idToObjectGroupName[parsedObjectId.id]; 611 var objectGroup = this._idToObjectGroupName[parsedObjectId.id];
612 var func = InjectedScriptHost.eval("(" + expression + ")"); 612 var func = InjectedScriptHost.eval("(" + expression + ")");
613 if (typeof func !== "function") 613 if (typeof func !== "function")
614 return "Given expression does not evaluate to a function"; 614 return "Given expression does not evaluate to a function";
615 615
616 return { wasThrown: false, 616 return { wasThrown: false,
617 result: this._wrapObject(func.apply(object, resolvedArgs), objectGroup, returnByValue), 617 result: this._wrapObject(func.apply(object, resolvedArgs), objectGroup, returnByValue),
618 __proto__: null }; 618 __proto__: null };
619 } catch (e) { 619 } catch (e) {
620 return this._createThrownValue(e, objectGroup); 620 return this._createThrownValue(e, objectGroup, false);
621 } 621 }
622 }, 622 },
623 623
624 /** 624 /**
625 * Resolves a value from CallArgument description. 625 * Resolves a value from CallArgument description.
626 * @param {!RuntimeAgent.CallArgument} callArgumentJson 626 * @param {!RuntimeAgent.CallArgument} callArgumentJson
627 * @return {*} resolved value 627 * @return {*} resolved value
628 * @throws {string} error message 628 * @throws {string} error message
629 */ 629 */
630 _resolveCallArgument: function(callArgumentJson) 630 _resolveCallArgument: function(callArgumentJson)
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 * @return {!Object} 663 * @return {!Object}
664 */ 664 */
665 _evaluateAndWrap: function(evalFunction, object, expression, objectGroup, is EvalOnCallFrame, injectCommandLineAPI, returnByValue, generatePreview, scopeChai n) 665 _evaluateAndWrap: function(evalFunction, object, expression, objectGroup, is EvalOnCallFrame, injectCommandLineAPI, returnByValue, generatePreview, scopeChai n)
666 { 666 {
667 var wrappedResult = this._evaluateOn(evalFunction, object, objectGroup, expression, isEvalOnCallFrame, injectCommandLineAPI, scopeChain); 667 var wrappedResult = this._evaluateOn(evalFunction, object, objectGroup, expression, isEvalOnCallFrame, injectCommandLineAPI, scopeChain);
668 if (!wrappedResult.exceptionDetails) { 668 if (!wrappedResult.exceptionDetails) {
669 return { wasThrown: false, 669 return { wasThrown: false,
670 result: this._wrapObject(wrappedResult.result, objectGroup, returnByValue, generatePreview), 670 result: this._wrapObject(wrappedResult.result, objectGroup, returnByValue, generatePreview),
671 __proto__: null }; 671 __proto__: null };
672 } 672 }
673 return this._createThrownValue(wrappedResult.result, objectGroup, wrappe dResult.exceptionDetails); 673 return this._createThrownValue(wrappedResult.result, objectGroup, genera tePreview, wrappedResult.exceptionDetails);
674 }, 674 },
675 675
676 /** 676 /**
677 * @param {*} value 677 * @param {*} value
678 * @param {string} objectGroup 678 * @param {string} objectGroup
679 * @param {boolean} generatePreview
679 * @param {!DebuggerAgent.ExceptionDetails=} exceptionDetails 680 * @param {!DebuggerAgent.ExceptionDetails=} exceptionDetails
680 * @return {!Object} 681 * @return {!Object}
681 */ 682 */
682 _createThrownValue: function(value, objectGroup, exceptionDetails) 683 _createThrownValue: function(value, objectGroup, generatePreview, exceptionD etails)
683 { 684 {
684 var remoteObject = this._wrapObject(value, objectGroup); 685 var remoteObject = this._wrapObject(value, objectGroup, false, generateP review && !(value instanceof Error));
685 try { 686 if (!remoteObject.description){
686 remoteObject.description = toStringDescription(value); 687 remoteObject.description = toStringDescription(value);
687 } catch (e) {} 688 }
688 return { wasThrown: true, result: remoteObject, exceptionDetails: except ionDetails, __proto__: null }; 689 return { wasThrown: true, result: remoteObject, exceptionDetails: except ionDetails, __proto__: null };
689 }, 690 },
690 691
691 /** 692 /**
692 * @param {!Function} evalFunction 693 * @param {!Function} evalFunction
693 * @param {!Object} object 694 * @param {!Object} object
694 * @param {string} objectGroup 695 * @param {string} objectGroup
695 * @param {string} expression 696 * @param {string} expression
696 * @param {boolean} isEvalOnCallFrame 697 * @param {boolean} isEvalOnCallFrame
697 * @param {boolean} injectCommandLineAPI 698 * @param {boolean} injectCommandLineAPI
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
1035 return toString(obj); 1036 return toString(obj);
1036 1037
1037 if (isSymbol(obj)) { 1038 if (isSymbol(obj)) {
1038 try { 1039 try {
1039 return Symbol.prototype.toString.call(obj) || "Symbol"; 1040 return Symbol.prototype.toString.call(obj) || "Symbol";
1040 } catch (e) { 1041 } catch (e) {
1041 return "Symbol"; 1042 return "Symbol";
1042 } 1043 }
1043 } 1044 }
1044 1045
1046 if (obj instanceof Error && !!obj.message)
vsevik 2014/07/18 14:41:06 Let's extract this change to a separate CL.
kozyatinskiy1 2014/07/18 16:10:08 Done.
1047 return className + ": " + obj.message;
1048
1045 return className; 1049 return className;
1046 } 1050 }
1047 } 1051 }
1048 1052
1049 /** 1053 /**
1050 * @type {!InjectedScript} 1054 * @type {!InjectedScript}
1051 * @const 1055 * @const
1052 */ 1056 */
1053 var injectedScript = new InjectedScript(); 1057 var injectedScript = new InjectedScript();
1054 1058
(...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after
1693 */ 1697 */
1694 _logEvent: function(event) 1698 _logEvent: function(event)
1695 { 1699 {
1696 inspectedWindow.console.log(event.type, event); 1700 inspectedWindow.console.log(event.type, event);
1697 } 1701 }
1698 } 1702 }
1699 1703
1700 injectedScript._commandLineAPIImpl = new CommandLineAPIImpl(); 1704 injectedScript._commandLineAPIImpl = new CommandLineAPIImpl();
1701 return injectedScript; 1705 return injectedScript;
1702 }) 1706 })
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698