feat: add standardized error codes for Express errors #6982
+489
−15
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Implements standardized error codes for Express-thrown errors as proposed in #6951.
Changes
lib/errors.jswith error code constants and factory helpersexpress.errorCodes(frozen object) for programmatic error handlingcodeproperty to all 15 errors thrown by ExpressError.captureStackTracefor clean stack tracesError Codes
ERR_INVALID_STATUS_CODEres.status()ERR_STATUS_CODE_OUT_OF_RANGEres.status()ERR_SENDFILE_PATH_REQUIREDres.sendFile()ERR_SENDFILE_PATH_NOT_STRINGres.sendFile()ERR_SENDFILE_PATH_NOT_ABSOLUTEres.sendFile()ERR_CONTENT_TYPE_ARRAYres.set()ERR_COOKIE_SECRET_REQUIREDres.cookie()ERR_MIDDLEWARE_REQUIREDapp.use()ERR_ENGINE_CALLBACK_REQUIREDapp.engine()ERR_HEADER_NAME_REQUIREDreq.get()ERR_HEADER_NAME_NOT_STRINGreq.get()ERR_NO_DEFAULT_ENGINEViewERR_VIEW_ENGINE_NOT_FOUNDViewERR_INVALID_ETAG_OPTIONapp.set('etag')ERR_INVALID_QUERY_PARSER_OPTIONapp.set('query parser')Usage
Closes #6951
Contribution by Gittensor, see my contribution statistics at https://gittensor.io/miners/details?githubId=132382032