Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoyee Cheung <joyeec9h3@gmail.com>2018-11-03 17:45:40 +0300
committerJoyee Cheung <joyeec9h3@gmail.com>2018-11-06 15:58:40 +0300
commit5850220229cdd8b62f6d5022779af7c232231d64 (patch)
tree7dbb9c7d94be088bebf535ec41ed4a8096af847e /src/node_contextify.cc
parent7b1297d856dbd9af85c18478301b234caebf04e4 (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_contextify.cc')
-rw-r--r--src/node_contextify.cc43
1 files changed, 1 insertions, 42 deletions
diff --git a/src/node_contextify.cc b/src/node_contextify.cc
index 79943f1ad6a..e878507731e 100644
--- a/src/node_contextify.cc
+++ b/src/node_contextify.cc
@@ -847,47 +847,6 @@ void ContextifyScript::RunInContext(const FunctionCallbackInfo<Value>& args) {
TRACING_CATEGORY_NODE2(vm, script), "RunInContext", wrapped_script);
}
-void ContextifyScript::DecorateErrorStack(
- Environment* env, const TryCatch& try_catch) {
- Local<Value> exception = try_catch.Exception();
-
- if (!exception->IsObject())
- return;
-
- Local<Object> err_obj = exception.As<Object>();
-
- if (IsExceptionDecorated(env, err_obj))
- return;
-
- AppendExceptionLine(env, exception, try_catch.Message(), CONTEXTIFY_ERROR);
- Local<Value> stack = err_obj->Get(env->stack_string());
- MaybeLocal<Value> maybe_value =
- err_obj->GetPrivate(
- env->context(),
- env->arrow_message_private_symbol());
-
- Local<Value> arrow;
- if (!(maybe_value.ToLocal(&arrow) && arrow->IsString())) {
- return;
- }
-
- if (stack.IsEmpty() || !stack->IsString()) {
- return;
- }
-
- Local<String> decorated_stack = String::Concat(
- env->isolate(),
- String::Concat(env->isolate(),
- arrow.As<String>(),
- FIXED_ONE_BYTE_STRING(env->isolate(), "\n")),
- stack.As<String>());
- err_obj->Set(env->stack_string(), decorated_stack);
- err_obj->SetPrivate(
- env->context(),
- env->decorated_private_symbol(),
- True(env->isolate()));
-}
-
bool ContextifyScript::EvalMachine(Environment* env,
const int64_t timeout,
const bool display_errors,
@@ -1080,7 +1039,7 @@ void ContextifyContext::CompileFunction(
Local<Function> fun;
if (maybe_fun.IsEmpty() || !maybe_fun.ToLocal(&fun)) {
- ContextifyScript::DecorateErrorStack(env, try_catch);
+ DecorateErrorStack(env, try_catch);
try_catch.ReThrow();
return;
}