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

Side by Side Diff: Source/core/inspector/InjectedScriptBase.cpp

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) 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 21 matching lines...) Expand all
32 32
33 33
34 #include "core/inspector/InjectedScriptBase.h" 34 #include "core/inspector/InjectedScriptBase.h"
35 35
36 #include "bindings/core/v8/ScriptFunctionCall.h" 36 #include "bindings/core/v8/ScriptFunctionCall.h"
37 #include "core/inspector/InspectorInstrumentation.h" 37 #include "core/inspector/InspectorInstrumentation.h"
38 #include "core/inspector/InspectorTraceEvents.h" 38 #include "core/inspector/InspectorTraceEvents.h"
39 #include "platform/JSONValues.h" 39 #include "platform/JSONValues.h"
40 #include "wtf/text/WTFString.h" 40 #include "wtf/text/WTFString.h"
41 41
42 using WebCore::TypeBuilder::Array;
42 using WebCore::TypeBuilder::Runtime::RemoteObject; 43 using WebCore::TypeBuilder::Runtime::RemoteObject;
43 44
44 namespace WebCore { 45 namespace WebCore {
45 46
46 InjectedScriptBase::InjectedScriptBase(const String& name) 47 InjectedScriptBase::InjectedScriptBase(const String& name)
47 : m_name(name) 48 : m_name(name)
48 , m_inspectedStateAccessCheck(0) 49 , m_inspectedStateAccessCheck(0)
49 { 50 {
50 } 51 }
51 52
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 ASSERT(!hadException); 115 ASSERT(!hadException);
115 if (!hadException) { 116 if (!hadException) {
116 *result = resultValue.toJSONValue(m_injectedScriptObject.scriptState()); 117 *result = resultValue.toJSONValue(m_injectedScriptObject.scriptState());
117 if (!*result) 118 if (!*result)
118 *result = JSONString::create(String::format("Object has too long ref erence chain(must not be longer than %d)", JSONValue::maxDepth)); 119 *result = JSONString::create(String::format("Object has too long ref erence chain(must not be longer than %d)", JSONValue::maxDepth));
119 } else { 120 } else {
120 *result = JSONString::create("Exception while making a call."); 121 *result = JSONString::create("Exception while making a call.");
121 } 122 }
122 } 123 }
123 124
124 void InjectedScriptBase::makeEvalCall(ErrorString* errorString, ScriptFunctionCa ll& function, RefPtr<TypeBuilder::Runtime::RemoteObject>* objectResult, TypeBuil der::OptOutput<bool>* wasThrown) 125 void InjectedScriptBase::makeEvalCall(ErrorString* errorString, ScriptFunctionCa ll& function, RefPtr<TypeBuilder::Runtime::RemoteObject>* objectResult, TypeBuil der::OptOutput<bool>* wasThrown, RefPtr<TypeBuilder::Debugger::ExceptionDetails> * objectExceptionDetails)
125 { 126 {
126 RefPtr<JSONValue> result; 127 RefPtr<JSONValue> result;
127 makeCall(function, &result); 128 makeCall(function, &result);
128 if (!result) { 129 if (!result) {
129 *errorString = "Internal error: result value is empty"; 130 *errorString = "Internal error: result value is empty";
130 return; 131 return;
131 } 132 }
132 if (result->type() == JSONValue::TypeString) { 133 if (result->type() == JSONValue::TypeString) {
133 result->asString(errorString); 134 result->asString(errorString);
134 ASSERT(errorString->length()); 135 ASSERT(errorString->length());
135 return; 136 return;
136 } 137 }
137 RefPtr<JSONObject> resultPair = result->asObject(); 138 RefPtr<JSONObject> resultPair = result->asObject();
138 if (!resultPair) { 139 if (!resultPair) {
139 *errorString = "Internal error: result is not an Object"; 140 *errorString = "Internal error: result is not an Object";
140 return; 141 return;
141 } 142 }
142 RefPtr<JSONObject> resultObj = resultPair->getObject("result"); 143 RefPtr<JSONObject> resultObj = resultPair->getObject("result");
143 bool wasThrownVal = false; 144 bool wasThrownVal = false;
144 if (!resultObj || !resultPair->getBoolean("wasThrown", &wasThrownVal)) { 145 if (!resultObj || !resultPair->getBoolean("wasThrown", &wasThrownVal)) {
145 *errorString = "Internal error: result is not a pair of value and wasThr own flag"; 146 *errorString = "Internal error: result is not a pair of value and wasThr own flag";
146 return; 147 return;
147 } 148 }
149 if (wasThrownVal) {
150 RefPtr<JSONObject> exceptionDetails = resultPair->getObject("exceptionDe tails");
aandrey 2014/07/04 16:57:25 so, where is it coming from? did you forget to add
151 if (objectExceptionDetails && exceptionDetails) {
152 String exceptionDetailsText;
153 if (exceptionDetails->getString("text", &exceptionDetailsText)) {
154 RefPtr<TypeBuilder::Debugger::ExceptionDetails> outputExceptionD etails = TypeBuilder::Debugger::ExceptionDetails::create().setText(exceptionDeta ilsText);
155 String url;
156 if (exceptionDetails->getString("url", &url))
157 outputExceptionDetails->setUrl(url);
158 int line = 0;
159 if (exceptionDetails->getNumber("line", &line))
160 outputExceptionDetails->setLine(line);
161 int column = 0;
162 if (exceptionDetails->getNumber("column", &column))
163 outputExceptionDetails->setColumn(column);
164 RefPtr<JSONArray> stackTrace = exceptionDetails->getArray("stack Trace");
165 if (stackTrace && stackTrace->length() > 0)
166 outputExceptionDetails->setStackTrace(Array<TypeBuilder::Con sole::CallFrame>::runtimeCast(stackTrace));
167 *objectExceptionDetails = outputExceptionDetails;
168 }
169 }
170 }
148 *objectResult = TypeBuilder::Runtime::RemoteObject::runtimeCast(resultObj); 171 *objectResult = TypeBuilder::Runtime::RemoteObject::runtimeCast(resultObj);
149 *wasThrown = wasThrownVal; 172 *wasThrown = wasThrownVal;
150 } 173 }
151 174
152 } // namespace WebCore 175 } // namespace WebCore
153 176
OLDNEW
« no previous file with comments | « Source/core/inspector/InjectedScriptBase.h ('k') | Source/core/inspector/InspectorDebuggerAgent.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698