diff options
author | Anna Henningsen <anna@addaleax.net> | 2018-02-23 22:28:29 +0100 |
---|---|---|
committer | Anatoli Papirovski <apapirovski@mac.com> | 2018-03-04 13:52:31 +0100 |
commit | 7bc8eb8da7ccdcd67edaf612b6599ec04ab77cb1 (patch) | |
tree | 49760a75c64906b4b959be477d923b11416c3ca4 /src/node_http2.cc | |
parent | f2b9805f85d3ff770892b37944a0890e0e60ca78 (diff) | |
download | android-node-v8-7bc8eb8da7ccdcd67edaf612b6599ec04ab77cb1.tar.gz android-node-v8-7bc8eb8da7ccdcd67edaf612b6599ec04ab77cb1.tar.bz2 android-node-v8-7bc8eb8da7ccdcd67edaf612b6599ec04ab77cb1.zip |
http2: refer to stream errors by name
Display the constant name instead of a stream error code
in the error message, because the numerical codes give absolutely
no clue about what happened when an error is emitted.
PR-URL: https://github.com/nodejs/node/pull/18966
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Diffstat (limited to 'src/node_http2.cc')
-rw-r--r-- | src/node_http2.cc | 59 |
1 files changed, 36 insertions, 23 deletions
diff --git a/src/node_http2.cc b/src/node_http2.cc index 7650969f86..4ec6e6e54f 100644 --- a/src/node_http2.cc +++ b/src/node_http2.cc @@ -2929,29 +2929,39 @@ void Initialize(Local<Object> target, session->GetFunction()).FromJust(); Local<Object> constants = Object::New(isolate); - NODE_DEFINE_CONSTANT(constants, NGHTTP2_SESSION_SERVER); - NODE_DEFINE_CONSTANT(constants, NGHTTP2_SESSION_CLIENT); - NODE_DEFINE_CONSTANT(constants, NGHTTP2_STREAM_STATE_IDLE); - NODE_DEFINE_CONSTANT(constants, NGHTTP2_STREAM_STATE_OPEN); - NODE_DEFINE_CONSTANT(constants, NGHTTP2_STREAM_STATE_RESERVED_LOCAL); - NODE_DEFINE_CONSTANT(constants, NGHTTP2_STREAM_STATE_RESERVED_REMOTE); - NODE_DEFINE_CONSTANT(constants, NGHTTP2_STREAM_STATE_HALF_CLOSED_LOCAL); - NODE_DEFINE_CONSTANT(constants, NGHTTP2_STREAM_STATE_HALF_CLOSED_REMOTE); - NODE_DEFINE_CONSTANT(constants, NGHTTP2_STREAM_STATE_CLOSED); - NODE_DEFINE_CONSTANT(constants, NGHTTP2_NO_ERROR); - NODE_DEFINE_CONSTANT(constants, NGHTTP2_PROTOCOL_ERROR); - NODE_DEFINE_CONSTANT(constants, NGHTTP2_INTERNAL_ERROR); - NODE_DEFINE_CONSTANT(constants, NGHTTP2_FLOW_CONTROL_ERROR); - NODE_DEFINE_CONSTANT(constants, NGHTTP2_SETTINGS_TIMEOUT); - NODE_DEFINE_CONSTANT(constants, NGHTTP2_STREAM_CLOSED); - NODE_DEFINE_CONSTANT(constants, NGHTTP2_FRAME_SIZE_ERROR); - NODE_DEFINE_CONSTANT(constants, NGHTTP2_REFUSED_STREAM); - NODE_DEFINE_CONSTANT(constants, NGHTTP2_CANCEL); - NODE_DEFINE_CONSTANT(constants, NGHTTP2_COMPRESSION_ERROR); - NODE_DEFINE_CONSTANT(constants, NGHTTP2_CONNECT_ERROR); - NODE_DEFINE_CONSTANT(constants, NGHTTP2_ENHANCE_YOUR_CALM); - NODE_DEFINE_CONSTANT(constants, NGHTTP2_INADEQUATE_SECURITY); - NODE_DEFINE_CONSTANT(constants, NGHTTP2_HTTP_1_1_REQUIRED); + Local<Array> name_for_error_code = Array::New(isolate); + +#define NODE_NGHTTP2_ERROR_CODES(V) \ + V(NGHTTP2_SESSION_SERVER); \ + V(NGHTTP2_SESSION_CLIENT); \ + V(NGHTTP2_STREAM_STATE_IDLE); \ + V(NGHTTP2_STREAM_STATE_OPEN); \ + V(NGHTTP2_STREAM_STATE_RESERVED_LOCAL); \ + V(NGHTTP2_STREAM_STATE_RESERVED_REMOTE); \ + V(NGHTTP2_STREAM_STATE_HALF_CLOSED_LOCAL); \ + V(NGHTTP2_STREAM_STATE_HALF_CLOSED_REMOTE); \ + V(NGHTTP2_STREAM_STATE_CLOSED); \ + V(NGHTTP2_NO_ERROR); \ + V(NGHTTP2_PROTOCOL_ERROR); \ + V(NGHTTP2_INTERNAL_ERROR); \ + V(NGHTTP2_FLOW_CONTROL_ERROR); \ + V(NGHTTP2_SETTINGS_TIMEOUT); \ + V(NGHTTP2_STREAM_CLOSED); \ + V(NGHTTP2_FRAME_SIZE_ERROR); \ + V(NGHTTP2_REFUSED_STREAM); \ + V(NGHTTP2_CANCEL); \ + V(NGHTTP2_COMPRESSION_ERROR); \ + V(NGHTTP2_CONNECT_ERROR); \ + V(NGHTTP2_ENHANCE_YOUR_CALM); \ + V(NGHTTP2_INADEQUATE_SECURITY); \ + V(NGHTTP2_HTTP_1_1_REQUIRED); \ + +#define V(name) \ + NODE_DEFINE_CONSTANT(constants, name); \ + name_for_error_code->Set(static_cast<int>(name), \ + FIXED_ONE_BYTE_STRING(isolate, #name)); + NODE_NGHTTP2_ERROR_CODES(V) +#undef V NODE_DEFINE_HIDDEN_CONSTANT(constants, NGHTTP2_HCAT_REQUEST); NODE_DEFINE_HIDDEN_CONSTANT(constants, NGHTTP2_HCAT_RESPONSE); @@ -3016,6 +3026,9 @@ HTTP_STATUS_CODES(V) target->Set(context, FIXED_ONE_BYTE_STRING(isolate, "constants"), constants).FromJust(); + target->Set(context, + FIXED_ONE_BYTE_STRING(isolate, "nameForErrorCode"), + name_for_error_code).FromJust(); } } // namespace http2 } // namespace node |