diff options
author | Rich Trott <rtrott@gmail.com> | 2018-09-20 06:04:47 +0300 |
---|---|---|
committer | Rich Trott <rtrott@gmail.com> | 2018-09-27 05:36:50 +0300 |
commit | f8d69911bef0ddd150d0f66f7a75b4655cf60b00 (patch) | |
tree | 7440234fc5d932a09f276db9f5f2c700fae7591c /src/node_errors.h | |
parent | 884dbe9b7f21414b628da43c7016de742ef39454 (diff) |
errors: use ERR_OUT_OF_RANGE for index errors
Remove ERR_INDEX_OUT_OF_RANGE in favor of ERR_OUT_OF_RANGE which is
capable of providing more detail. (In one instance, use
ERR_BUFFER_OUT_OF_BOUNDS which is more accurate in that one instance.)
PR-URL: https://github.com/nodejs/node/pull/22969
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Weijia Wang <starkwang@126.com>
Diffstat (limited to 'src/node_errors.h')
-rw-r--r-- | src/node_errors.h | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/node_errors.h b/src/node_errors.h index fdfb670af63..233a0f7532c 100644 --- a/src/node_errors.h +++ b/src/node_errors.h @@ -26,7 +26,6 @@ namespace node { V(ERR_CANNOT_TRANSFER_OBJECT, TypeError) \ V(ERR_CLOSED_MESSAGE_PORT, Error) \ V(ERR_CONSTRUCT_CALL_REQUIRED, Error) \ - V(ERR_INDEX_OUT_OF_RANGE, RangeError) \ V(ERR_INVALID_ARG_VALUE, TypeError) \ V(ERR_INVALID_ARG_TYPE, TypeError) \ V(ERR_INVALID_TRANSFER_OBJECT, TypeError) \ @@ -35,6 +34,7 @@ namespace node { V(ERR_MISSING_MESSAGE_PORT_IN_TRANSFER_LIST, TypeError) \ V(ERR_MISSING_MODULE, Error) \ V(ERR_MISSING_PLATFORM_FOR_WORKER, Error) \ + V(ERR_OUT_OF_RANGE, RangeError) \ V(ERR_SCRIPT_EXECUTION_INTERRUPTED, Error) \ V(ERR_SCRIPT_EXECUTION_TIMEOUT, Error) \ V(ERR_STRING_TOO_LONG, Error) \ @@ -64,7 +64,6 @@ namespace node { V(ERR_CANNOT_TRANSFER_OBJECT, "Cannot transfer object of unsupported type")\ V(ERR_CLOSED_MESSAGE_PORT, "Cannot send data on closed MessagePort") \ V(ERR_CONSTRUCT_CALL_REQUIRED, "Cannot call constructor without `new`") \ - V(ERR_INDEX_OUT_OF_RANGE, "Index out of range") \ V(ERR_INVALID_TRANSFER_OBJECT, "Found invalid object in transferList") \ V(ERR_MEMORY_ALLOCATION_FAILED, "Failed to allocate memory") \ V(ERR_MISSING_MESSAGE_PORT_IN_TRANSFER_LIST, \ @@ -96,6 +95,13 @@ inline void THROW_ERR_SCRIPT_EXECUTION_TIMEOUT(Environment* env, THROW_ERR_SCRIPT_EXECUTION_TIMEOUT(env, message.str().c_str()); } +inline void THROW_ERR_OUT_OF_RANGE_WITH_TEXT(Environment* env, + const char* messageText) { + std::ostringstream message; + message << messageText; + THROW_ERR_OUT_OF_RANGE(env, message.str().c_str()); +} + inline v8::Local<v8::Value> ERR_BUFFER_TOO_LARGE(v8::Isolate* isolate) { char message[128]; snprintf(message, sizeof(message), |