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:
authorAnna Henningsen <anna@addaleax.net>2020-04-27 04:36:23 +0300
committerAnna Henningsen <anna@addaleax.net>2020-04-29 06:12:48 +0300
commitef85bd1908e9550e59dbfa16372b79c1a95ea2a8 (patch)
treecc0a3e4e5bd28ef5f6d42bb396167850ad4196f0 /src/node_worker.h
parent11bc30d5cc000614b9168d7989082e8c1a69be28 (diff)
worker: unify custom error creation
Mostly, this introduces a pattern that makes sure that if a custom error is reported, `stopped_` will be set to `true` correctly in every cast, which was previously missing for the `NewContext().IsEmpty()` case (which led to a hard crash from the `Worker` destructor). This also leaves TODO comments for a few cases in which `ERR_WORKER_OUT_OF_MEMORY` was not used in accordance with the documentation for that error code (or according to its intention). Fixing that is semver-major. PR-URL: https://github.com/nodejs/node/pull/33084 Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'src/node_worker.h')
-rw-r--r--src/node_worker.h7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/node_worker.h b/src/node_worker.h
index b962e5757a6..f9deaa59b4a 100644
--- a/src/node_worker.h
+++ b/src/node_worker.h
@@ -34,8 +34,11 @@ class Worker : public AsyncWrap {
void Run();
// Forcibly exit the thread with a specified exit code. This may be called
- // from any thread.
- void Exit(int code);
+ // from any thread. `error_code` and `error_message` can be used to create
+ // a custom `'error'` event before emitting `'exit'`.
+ void Exit(int code,
+ const char* error_code = nullptr,
+ const char* error_message = nullptr);
// Wait for the worker thread to stop (in a blocking manner).
void JoinThread();