diff options
author | Felix Geisendörfer <felix@debuggable.com> | 2011-12-18 15:55:40 +0100 |
---|---|---|
committer | isaacs <i@izs.me> | 2012-03-19 19:00:16 -0700 |
commit | 18240193ba421695d984c3d73e88de7e1b324e0a (patch) | |
tree | 9272cc0d8b51c5ff63f04b855975e1733f29ff5e /src | |
parent | 891f9defeb9713d8da9428195ad594a6d3627400 (diff) | |
download | node-18240193ba421695d984c3d73e88de7e1b324e0a.tar.gz |
Expose http parse error codes
Currently http parse errors do not expose the error details available
from http_parser. This patch exposes the error code as `err.code`.
Diffstat (limited to 'src')
-rw-r--r-- | src/node_http_parser.cc | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/node_http_parser.cc b/src/node_http_parser.cc index f6559ee8b..a6c77bca1 100644 --- a/src/node_http_parser.cc +++ b/src/node_http_parser.cc @@ -432,9 +432,12 @@ public: // If there was a parse error in one of the callbacks // TODO What if there is an error on EOF? if (!parser->parser_.upgrade && nparsed != len) { + enum http_errno err = HTTP_PARSER_ERRNO(&parser->parser_); + Local<Value> e = Exception::Error(String::NewSymbol("Parse Error")); Local<Object> obj = e->ToObject(); obj->Set(String::NewSymbol("bytesParsed"), nparsed_obj); + obj->Set(String::NewSymbol("code"), String::New(http_errno_name(err))); return scope.Close(e); } else { return scope.Close(nparsed_obj); @@ -455,9 +458,12 @@ public: if (parser->got_exception_) return Local<Value>(); if (rv != 0) { + enum http_errno err = HTTP_PARSER_ERRNO(&parser->parser_); + Local<Value> e = Exception::Error(String::NewSymbol("Parse Error")); Local<Object> obj = e->ToObject(); obj->Set(String::NewSymbol("bytesParsed"), Integer::New(0)); + obj->Set(String::NewSymbol("code"), String::New(http_errno_name(err))); return scope.Close(e); } |