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

Unified Diff: Source/bindings/v8/V8Utilities.cpp

Issue 38063003: Improve TypeError messages from failed array conversions. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Improve TypeError messages from failed array conversions. Created 7 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/bindings/v8/V8Utilities.h ('k') | Source/bindings/v8/custom/V8DedicatedWorkerGlobalScopeCustom.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/v8/V8Utilities.cpp
diff --git a/Source/bindings/v8/V8Utilities.cpp b/Source/bindings/v8/V8Utilities.cpp
index 62ea7eb3f7a26703038b18f92b5d809991ce191d..5d8b2995775e4fc6b864d2e25b00f8736909eb6d 100644
--- a/Source/bindings/v8/V8Utilities.cpp
+++ b/Source/bindings/v8/V8Utilities.cpp
@@ -32,6 +32,7 @@
#include "bindings/v8/V8Utilities.h"
#include "V8MessagePort.h"
+#include "bindings/v8/ExceptionMessages.h"
#include "bindings/v8/ScriptState.h"
#include "bindings/v8/V8AbstractEventListener.h"
#include "bindings/v8/V8Binding.h"
@@ -76,7 +77,7 @@ bool extractTransferables(v8::Local<v8::Value> value, MessagePortArray& ports, A
v8::Local<v8::Array> array = v8::Local<v8::Array>::Cast(value);
length = array->Length();
} else {
- if (toV8Sequence(value, length, &notASequence, isolate).IsEmpty())
+ if (toV8Sequence(value, length, notASequence, isolate).IsEmpty())
return false;
}
@@ -109,18 +110,33 @@ bool extractTransferables(v8::Local<v8::Value> value, MessagePortArray& ports, A
return true;
}
-bool getMessagePortArray(v8::Local<v8::Value> value, MessagePortArray& ports, v8::Isolate* isolate)
+bool getMessagePortArray(v8::Local<v8::Value> value, const String& propertyName, MessagePortArray& ports, v8::Isolate* isolate)
{
if (isUndefinedOrNull(value)) {
ports.resize(0);
return true;
}
if (!value->IsArray()) {
- throwUninformativeAndGenericTypeError(isolate);
+ throwTypeError(ExceptionMessages::notASequenceTypeProperty(propertyName), isolate);
return false;
}
bool success = false;
- ports = toRefPtrNativeArray<MessagePort, V8MessagePort>(value, isolate, &success);
+ ports = toRefPtrNativeArray<MessagePort, V8MessagePort>(value, propertyName, isolate, &success);
+ return success;
+}
+
+bool getMessagePortArray(v8::Local<v8::Value> value, int argumentIndex, MessagePortArray& ports, v8::Isolate* isolate)
+{
+ if (isUndefinedOrNull(value)) {
+ ports.resize(0);
+ return true;
+ }
+ if (!value->IsArray()) {
+ throwTypeError(ExceptionMessages::notASequenceTypeArgumentOrValue(argumentIndex), isolate);
+ return false;
+ }
+ bool success = false;
+ ports = toRefPtrNativeArray<MessagePort, V8MessagePort>(value, argumentIndex, isolate, &success);
return success;
}
« no previous file with comments | « Source/bindings/v8/V8Utilities.h ('k') | Source/bindings/v8/custom/V8DedicatedWorkerGlobalScopeCustom.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698