From 5850220229cdd8b62f6d5022779af7c232231d64 Mon Sep 17 00:00:00 2001 From: Joyee Cheung Date: Sat, 3 Nov 2018 22:45:40 +0800 Subject: 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 Reviewed-By: Daniel Bevenius --- src/node_internals.h | 111 +++++++++++++++++++-------------------------------- 1 file changed, 40 insertions(+), 71 deletions(-) (limited to 'src/node_internals.h') diff --git a/src/node_internals.h b/src/node_internals.h index b307019852..b83c23681b 100644 --- a/src/node_internals.h +++ b/src/node_internals.h @@ -102,46 +102,46 @@ struct sockaddr; // function. This helps the built-in modules are loaded properly when // node is built as static library. No need to depend on the // __attribute__((constructor)) like mechanism in GCC. -#define NODE_BUILTIN_STANDARD_MODULES(V) \ - V(async_wrap) \ - V(buffer) \ - V(cares_wrap) \ - V(config) \ - V(contextify) \ - V(domain) \ - V(fs) \ - V(fs_event_wrap) \ - V(heap_utils) \ - V(http2) \ - V(http_parser) \ - V(inspector) \ - V(js_stream) \ - V(messaging) \ - V(module_wrap) \ - V(options) \ - V(os) \ - V(performance) \ - V(pipe_wrap) \ - V(process_wrap) \ - V(serdes) \ - V(signal_wrap) \ - V(spawn_sync) \ - V(stream_pipe) \ - V(stream_wrap) \ - V(string_decoder) \ - V(symbols) \ - V(tcp_wrap) \ - V(timers) \ - V(trace_events) \ - V(tty_wrap) \ - V(types) \ - V(udp_wrap) \ - V(url) \ - V(util) \ - V(uv) \ - V(v8) \ - V(worker) \ - V(zlib) +#define NODE_BUILTIN_STANDARD_MODULES(V) \ + V(async_wrap) \ + V(buffer) \ + V(cares_wrap) \ + V(config) \ + V(contextify) \ + V(domain) \ + V(fs) \ + V(fs_event_wrap) \ + V(heap_utils) \ + V(http2) \ + V(http_parser) \ + V(inspector) \ + V(js_stream) \ + V(messaging) \ + V(module_wrap) \ + V(options) \ + V(os) \ + V(performance) \ + V(pipe_wrap) \ + V(process_wrap) \ + V(serdes) \ + V(signal_wrap) \ + V(spawn_sync) \ + V(stream_pipe) \ + V(stream_wrap) \ + V(string_decoder) \ + V(symbols) \ + V(tcp_wrap) \ + V(timers) \ + V(trace_events) \ + V(tty_wrap) \ + V(types) \ + V(udp_wrap) \ + V(url) \ + V(util) \ + V(uv) \ + V(v8) \ + V(worker) \ + V(zlib) #define NODE_BUILTIN_MODULES(V) \ NODE_BUILTIN_STANDARD_MODULES(V) \ @@ -214,11 +214,6 @@ void GetSockOrPeerName(const v8::FunctionCallbackInfo& args) { args.GetReturnValue().Set(err); } -void FatalException(v8::Isolate* isolate, - v8::Local error, - v8::Local message); - - void SignalExit(int signo); #ifdef __POSIX__ void RegisterSignalHandler(int signal, @@ -244,27 +239,6 @@ constexpr size_t arraysize(const T(&)[N]) { return N; } # define MUST_USE_RESULT #endif -bool IsExceptionDecorated(Environment* env, v8::Local er); - -enum ErrorHandlingMode { CONTEXTIFY_ERROR, FATAL_ERROR, MODULE_ERROR }; -void AppendExceptionLine(Environment* env, - v8::Local er, - v8::Local message, - enum ErrorHandlingMode mode); - -[[noreturn]] void FatalError(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_; -}; - class SlicedArguments { public: inline explicit SlicedArguments( @@ -298,10 +272,6 @@ SlicedArguments::SlicedArguments( size_ = size; } -void ReportException(Environment* env, - v8::Local er, - v8::Local message); - v8::Maybe ProcessEmitWarning(Environment* env, const char* fmt, ...); v8::Maybe ProcessEmitDeprecationWarning(Environment* env, const char* warning, @@ -829,7 +799,6 @@ static inline const char* errno_string(int errorno) { // Functions defined in node.cc that are exposed via the bootstrapper object extern double prog_start_time; -void PrintErrorString(const char* format, ...); void Abort(const v8::FunctionCallbackInfo& args); void Chdir(const v8::FunctionCallbackInfo& args); -- cgit v1.2.3