summaryrefslogtreecommitdiff
path: root/src/node_errors.h
diff options
context:
space:
mode:
authorJoyee Cheung <joyeec9h3@gmail.com>2018-04-19 18:41:33 +0800
committerJoyee Cheung <joyeec9h3@gmail.com>2018-04-25 23:46:08 +0800
commit3152b7c0d329893d2fe9f74ff4f334d182a10545 (patch)
treea79c4d4e578bf30020f19c6a71311ab748d34b52 /src/node_errors.h
parent94e0e2c787deade5702026b6d6eea8dcfee3b6a3 (diff)
downloadandroid-node-v8-3152b7c0d329893d2fe9f74ff4f334d182a10545.tar.gz
android-node-v8-3152b7c0d329893d2fe9f74ff4f334d182a10545.tar.bz2
android-node-v8-3152b7c0d329893d2fe9f74ff4f334d182a10545.zip
src: assign ERR_SCRIPT_EXECUTION_* codes in C++
Also modifies the error messages so they include more information and are more consistent. - The message of ERR_SCRIPT_EXECUTION_INTERRUPTED now mentions SIGINT and the trailing period is dropped for consistency. - Added ERR_SCRIPT_EXECUTION_TIMEOUT and include the timeout in the message. PR-URL: https://github.com/nodejs/node/pull/20147 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Michaƫl Zasso <targos@protonmail.com> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Diffstat (limited to 'src/node_errors.h')
-rw-r--r--src/node_errors.h17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/node_errors.h b/src/node_errors.h
index 0f91872474..eb120c6280 100644
--- a/src/node_errors.h
+++ b/src/node_errors.h
@@ -8,6 +8,10 @@
#include "env-inl.h"
#include "v8.h"
+// Use ostringstream to print exact-width integer types
+// because the format specifiers are not available on AIX.
+#include <sstream>
+
namespace node {
// Helpers to construct errors similar to the ones provided by
@@ -24,6 +28,8 @@ namespace node {
V(ERR_MEMORY_ALLOCATION_FAILED, Error) \
V(ERR_MISSING_ARGS, TypeError) \
V(ERR_MISSING_MODULE, Error) \
+ V(ERR_SCRIPT_EXECUTION_INTERRUPTED, Error) \
+ V(ERR_SCRIPT_EXECUTION_TIMEOUT, Error) \
V(ERR_STRING_TOO_LONG, Error) \
V(ERR_BUFFER_TOO_LARGE, Error)
@@ -49,7 +55,9 @@ namespace node {
#define PREDEFINED_ERROR_MESSAGES(V) \
V(ERR_INDEX_OUT_OF_RANGE, "Index out of range") \
- V(ERR_MEMORY_ALLOCATION_FAILED, "Failed to allocate memory")
+ V(ERR_MEMORY_ALLOCATION_FAILED, "Failed to allocate memory") \
+ V(ERR_SCRIPT_EXECUTION_INTERRUPTED, \
+ "Script execution was interrupted by `SIGINT`")
#define V(code, message) \
inline v8::Local<v8::Value> code(v8::Isolate* isolate) { \
@@ -62,6 +70,13 @@ namespace node {
#undef V
// Errors with predefined non-static messages
+inline void THROW_ERR_SCRIPT_EXECUTION_TIMEOUT(Environment* env,
+ int64_t timeout) {
+ std::ostringstream message;
+ message << "Script execution timed out after ";
+ message << timeout << "ms";
+ THROW_ERR_SCRIPT_EXECUTION_TIMEOUT(env, message.str().c_str());
+}
inline v8::Local<v8::Value> ERR_BUFFER_TOO_LARGE(v8::Isolate *isolate) {
char message[128];