diff options
author | Joyee Cheung <joyeec9h3@gmail.com> | 2018-11-03 17:45:40 +0300 |
---|---|---|
committer | Joyee Cheung <joyeec9h3@gmail.com> | 2018-11-06 15:58:40 +0300 |
commit | 5850220229cdd8b62f6d5022779af7c232231d64 (patch) | |
tree | 7dbb9c7d94be088bebf535ec41ed4a8096af847e /src/node_errors.h | |
parent | 7b1297d856dbd9af85c18478301b234caebf04e4 (diff) |
src: move error handling code into node_errors.cc
Move the following code into a new node_errors.cc file and
declare them in node_errors.h for clarity and make it possible
to include them with node_errors.h.
- AppendExceptionLine()
- DecorateErrorStack()
- FatalError()
- OnFatalError()
- PrintErrorString()
- FatalException()
- ReportException()
- FatalTryCatch
And move the following definitions (declared elsewhere than
node_errors.h) to node_errors.cc:
- Abort() (in util.h)
- Assert() (in util.h)
PR-URL: https://github.com/nodejs/node/pull/24058
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Diffstat (limited to 'src/node_errors.h')
-rw-r--r-- | src/node_errors.h | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/node_errors.h b/src/node_errors.h index a435695693b..2c52007c511 100644 --- a/src/node_errors.h +++ b/src/node_errors.h @@ -14,6 +14,38 @@ namespace node { +void DecorateErrorStack(Environment* env, const v8::TryCatch& try_catch); + +enum ErrorHandlingMode { CONTEXTIFY_ERROR, FATAL_ERROR, MODULE_ERROR }; +void AppendExceptionLine(Environment* env, + v8::Local<v8::Value> er, + v8::Local<v8::Message> message, + enum ErrorHandlingMode mode); + +[[noreturn]] void FatalError(const char* location, const char* message); +void OnFatalError(const char* location, const char* message); + +// Like a `TryCatch` but exits the process if an exception was caught. +class FatalTryCatch : public v8::TryCatch { + public: + explicit FatalTryCatch(Environment* env) + : TryCatch(env->isolate()), env_(env) {} + ~FatalTryCatch(); + + private: + Environment* env_; +}; + +void PrintErrorString(const char* format, ...); + +void ReportException(Environment* env, const v8::TryCatch& try_catch); + +void FatalException(v8::Isolate* isolate, + v8::Local<v8::Value> error, + v8::Local<v8::Message> message); + +void FatalException(const v8::FunctionCallbackInfo<v8::Value>& args); + // Helpers to construct errors similar to the ones provided by // lib/internal/errors.js. // Example: with `V(ERR_INVALID_ARG_TYPE, TypeError)`, there will be |