Permalink
Browse files

TypedArrays: Update some exception messages to match WebKit.

  • Loading branch information...
1 parent e703b0c commit a203899d2a13d9580799d77827af19d32382885e @deanm committed Dec 19, 2012
Showing with 10 additions and 10 deletions.
  1. +10 −10 src/v8_typed_array.cc
View
@@ -131,7 +131,7 @@ class ArrayBuffer {
static v8::Handle<v8::Value> slice(const v8::Arguments& args) {
if (args.Length() < 1)
- return ThrowError("Wrong number of arguments.");
+ return ThrowTypeError("Not enough arguments");
unsigned int length =
args.This()->Get(v8::String::New("byteLength"))->Uint32Value();
@@ -602,7 +602,7 @@ class DataView {
return ThrowTypeError("Constructor cannot be called as a function.");
if (args.Length() < 1)
- return ThrowError("Wrong number of arguments.");
+ return ThrowTypeError("Not enough arguments");
if (!args[0]->IsObject())
return ThrowError("Object must be an ArrayBuffer.");
@@ -616,16 +616,16 @@ class DataView {
unsigned int byte_offset = args[1]->Uint32Value();
if (args[1]->Int32Value() < 0 || byte_offset >= byte_length)
- return ThrowRangeError("byteOffset out of range.");
+ return ThrowRangeError("Size is too large (or is negative).");
if (!args[2]->IsUndefined()) {
if (args[2]->Int32Value() < 0)
- return ThrowRangeError("byteLength out of range.");
+ return ThrowRangeError("Size is too large (or is negative).");
unsigned int new_byte_length = args[2]->Uint32Value();
if (new_byte_length > byte_length)
- return ThrowRangeError("byteLength out of range.");
+ return ThrowRangeError("Size is too large (or is negative).");
if (byte_offset + new_byte_length > byte_length)
- return ThrowRangeError("byteOffset/byteLength out of range.");
+ return ThrowRangeError("Size is too large (or is negative).");
byte_length = new_byte_length;
} else {
// Adjust the original byte_length from total length to length to end.
@@ -654,7 +654,7 @@ class DataView {
template <typename T>
static v8::Handle<v8::Value> getGeneric(const v8::Arguments& args) {
if (args.Length() < 1)
- return ThrowError("Wrong number of arguments.");
+ return ThrowTypeError("Not enough arguments");
unsigned int index = args[0]->Uint32Value();
bool little_endian = args[1]->BooleanValue();
@@ -666,7 +666,7 @@ class DataView {
// TODO(deanm): integer overflow.
if (index + sizeof(T) > static_cast<unsigned int>(size))
- return ThrowError("Index out of range.");
+ return ThrowError("IndexSizeError: DOM Exception 1");
void* ptr = reinterpret_cast<char*>(
args.This()->GetIndexedPropertiesExternalArrayData()) + index;
@@ -687,7 +687,7 @@ class DataView {
template <typename T>
static v8::Handle<v8::Value> setGeneric(const v8::Arguments& args) {
if (args.Length() < 2)
- return ThrowError("Wrong number of arguments.");
+ return ThrowTypeError("Not enough arguments");
unsigned int index = args[0]->Int32Value();
bool little_endian = args[2]->BooleanValue();
@@ -699,7 +699,7 @@ class DataView {
// TODO(deanm): integer overflow.
if (index + sizeof(T) > static_cast<unsigned int>(size))
- return ThrowError("Index out of range.");
+ return ThrowError("IndexSizeError: DOM Exception 1");
void* ptr = reinterpret_cast<char*>(
args.This()->GetIndexedPropertiesExternalArrayData()) + index;

0 comments on commit a203899

Please sign in to comment.