src: rename ERR_STRING_TOO_LARGE to ERR_STRING_TOO_LONG by joyeecheung · Pull Request #19864 · nodejs/node · GitHub
Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions doc/api/errors.md
8 changes: 4 additions & 4 deletions src/node_errors.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace node {

#define ERRORS_WITH_CODE(V) \
V(ERR_MEMORY_ALLOCATION_FAILED, Error) \
V(ERR_STRING_TOO_LARGE, Error) \
V(ERR_STRING_TOO_LONG, Error) \
V(ERR_BUFFER_TOO_LARGE, Error)

#define V(code, type) \
Expand Down Expand Up @@ -58,12 +58,12 @@ inline v8::Local<v8::Value> ERR_BUFFER_TOO_LARGE(v8::Isolate *isolate) {
return ERR_BUFFER_TOO_LARGE(isolate, message);
}

inline v8::Local<v8::Value> ERR_STRING_TOO_LARGE(v8::Isolate *isolate) {
inline v8::Local<v8::Value> ERR_STRING_TOO_LONG(v8::Isolate *isolate) {
char message[128];
snprintf(message, sizeof(message),
"Cannot create a string larger than 0x%x bytes",
"Cannot create a string longer than 0x%x characters",
v8::String::kMaxLength);
return ERR_STRING_TOO_LARGE(isolate, message);
return ERR_STRING_TOO_LONG(isolate, message);
}

} // namespace node
Expand Down
8 changes: 4 additions & 4 deletions src/string_bytes.cc
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class ExternString: public ResourceType {

if (str.IsEmpty()) {
delete h_str;
*error = node::ERR_STRING_TOO_LARGE(isolate);
*error = node::ERR_STRING_TOO_LONG(isolate);
return MaybeLocal<Value>();
}

Expand Down Expand Up @@ -170,7 +170,7 @@ MaybeLocal<Value> ExternOneByteString::NewSimpleFromCopy(Isolate* isolate,
v8::NewStringType::kNormal,
length);
if (str.IsEmpty()) {
*error = node::ERR_STRING_TOO_LARGE(isolate);
*error = node::ERR_STRING_TOO_LONG(isolate);
return MaybeLocal<Value>();
}
return str.ToLocalChecked();
Expand All @@ -188,7 +188,7 @@ MaybeLocal<Value> ExternTwoByteString::NewSimpleFromCopy(Isolate* isolate,
v8::NewStringType::kNormal,
length);
if (str.IsEmpty()) {
*error = node::ERR_STRING_TOO_LARGE(isolate);
*error = node::ERR_STRING_TOO_LONG(isolate);
return MaybeLocal<Value>();
}
return str.ToLocalChecked();
Expand Down Expand Up @@ -657,7 +657,7 @@ MaybeLocal<Value> StringBytes::Encode(Isolate* isolate,
v8::NewStringType::kNormal,
buflen);
if (val.IsEmpty()) {
*error = node::ERR_STRING_TOO_LARGE(isolate);
*error = node::ERR_STRING_TOO_LONG(isolate);
return MaybeLocal<Value>();
}
return val.ToLocalChecked();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ const stringLengthHex = kStringMaxLength.toString(16);
common.expectsError(function() {
buf.toString('ascii');
}, {
message: `Cannot create a string larger than 0x${stringLengthHex} bytes`,
code: 'ERR_STRING_TOO_LARGE',
message: `Cannot create a string longer than 0x${stringLengthHex} ` +
'characters',
code: 'ERR_STRING_TOO_LONG',
type: Error
});
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ const stringLengthHex = kStringMaxLength.toString(16);
common.expectsError(function() {
buf.toString('base64');
}, {
message: `Cannot create a string larger than 0x${stringLengthHex} bytes`,
code: 'ERR_STRING_TOO_LARGE',
message: `Cannot create a string longer than 0x${stringLengthHex} ` +
'characters',
code: 'ERR_STRING_TOO_LONG',
type: Error
});
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ const stringLengthHex = kStringMaxLength.toString(16);
common.expectsError(function() {
buf.toString('latin1');
}, {
message: `Cannot create a string larger than 0x${stringLengthHex} bytes`,
code: 'ERR_STRING_TOO_LARGE',
message: `Cannot create a string longer than 0x${stringLengthHex} ` +
'characters',
code: 'ERR_STRING_TOO_LONG',
type: Error
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ const stringLengthHex = kStringMaxLength.toString(16);
common.expectsError(function() {
buf.toString('hex');
}, {
message: `Cannot create a string larger than 0x${stringLengthHex} bytes`,
code: 'ERR_STRING_TOO_LARGE',
message: `Cannot create a string longer than 0x${stringLengthHex} ` +
'characters',
code: 'ERR_STRING_TOO_LONG',
type: Error
});
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ assert.throws(function() {
}, function(e) {
if (e.message !== 'Array buffer allocation failed') {
common.expectsError({
message: `Cannot create a string larger than 0x${stringLengthHex} bytes`,
code: 'ERR_STRING_TOO_LARGE',
message: `Cannot create a string longer than 0x${stringLengthHex} ` +
'characters',
code: 'ERR_STRING_TOO_LONG',
type: Error
})(e);
return true;
Expand All @@ -45,7 +46,8 @@ assert.throws(function() {
common.expectsError(function() {
buf.toString('utf8');
}, {
message: `Cannot create a string larger than 0x${stringLengthHex} bytes`,
code: 'ERR_STRING_TOO_LARGE',
message: `Cannot create a string longer than 0x${stringLengthHex} ` +
'characters',
code: 'ERR_STRING_TOO_LONG',
type: Error
});
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ const stringLengthHex = kStringMaxLength.toString(16);
common.expectsError(function() {
buf.toString('utf16le');
}, {
message: `Cannot create a string larger than 0x${stringLengthHex} bytes`,
code: 'ERR_STRING_TOO_LARGE',
message: `Cannot create a string longer than 0x${stringLengthHex} ` +
'characters',
code: 'ERR_STRING_TOO_LONG',
type: Error
});
6 changes: 3 additions & 3 deletions test/sequential/test-fs-readfile-tostring-fail.js