diff options
author | Anna Henningsen <anna@addaleax.net> | 2017-12-02 00:04:56 +0100 |
---|---|---|
committer | Ruben Bridgewater <ruben@bridgewater.de> | 2017-12-12 17:47:37 -0200 |
commit | f3cd53751ba3f917a0996a8f38c991242a8fbc76 (patch) | |
tree | 9eb646ad85977b1b4dd7656b8efa35f164808bd6 /src/node_internals.h | |
parent | ef49f55e9376cdc2ef99f3e4cd3021d3a253a1c9 (diff) | |
download | android-node-v8-f3cd53751ba3f917a0996a8f38c991242a8fbc76.tar.gz android-node-v8-f3cd53751ba3f917a0996a8f38c991242a8fbc76.tar.bz2 android-node-v8-f3cd53751ba3f917a0996a8f38c991242a8fbc76.zip |
src: refactor and harden `ProcessEmitWarning()`
- Handle exceptions when getting `process.emitWarning` or when
calling it properly
- Add `Maybe<bool>` to the return type, like the V8 API uses it
to indicate failure conditions
- Update call sites to account for that and clean up/return to JS
when encountering an error
- Add an internal `ProcessEmitDeprecationWarning()` sibling
for use in https://github.com/nodejs/node/pull/17417,
with common code extracted to a helper function
- Allow the warning to contain non-Latin-1 characters. Since the
message will usually be a template string containing data passed
from the user, this is the right thing to do.
- Add tests for the failure modes (except string creation failures)
and UTF-8 warning messages.
PR-URL: https://github.com/nodejs/node/pull/17420
Refs: https://github.com/nodejs/node/pull/17417
Reviewed-By: Andreas Madsen <amwebdk@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Diffstat (limited to 'src/node_internals.h')
-rw-r--r-- | src/node_internals.h | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/node_internals.h b/src/node_internals.h index 5466736200..09bcbba6e0 100644 --- a/src/node_internals.h +++ b/src/node_internals.h @@ -287,7 +287,10 @@ class FatalTryCatch : public v8::TryCatch { Environment* env_; }; -void ProcessEmitWarning(Environment* env, const char* fmt, ...); +v8::Maybe<bool> ProcessEmitWarning(Environment* env, const char* fmt, ...); +v8::Maybe<bool> ProcessEmitDeprecationWarning(Environment* env, + const char* warning, + const char* deprecation_code); void FillStatsArray(double* fields, const uv_stat_t* s); |