mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
http: improve parser error messages
Include the library-provided reason in the Error’s `message`. Fixes: https://github.com/nodejs/node/issues/28468 PR-URL: https://github.com/nodejs/node/pull/28487 Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
This commit is contained in:
committed by
Rich Trott
parent
fd23c12263
commit
ba565a3734
@@ -239,6 +239,12 @@ function cleanParser(parser) {
|
||||
parser._consumed = false;
|
||||
}
|
||||
|
||||
function prepareError(err, parser, rawPacket) {
|
||||
err.rawPacket = rawPacket || parser.getCurrentBuffer();
|
||||
if (typeof err.reason === 'string')
|
||||
err.message = `Parse Error: ${err.reason}`;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
_checkInvalidHeaderChar: checkInvalidHeaderChar,
|
||||
_checkIsHttpToken: checkIsHttpToken,
|
||||
@@ -251,5 +257,6 @@ module.exports = {
|
||||
methods,
|
||||
parsers,
|
||||
kIncomingMessage,
|
||||
HTTPParser
|
||||
HTTPParser,
|
||||
prepareError,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user