Skip to content

feat(rest): export helper to map error codes to status codes - #11942

Open
piyushbinjhade wants to merge 1 commit into
loopbackio:masterfrom
piyushbinjhade:feat/reject-status-code-mapping
Open

piyushbinjhade wants to merge 1 commit into
loopbackio:masterfrom
piyushbinjhade:feat/reject-status-code-mapping

Conversation

@piyushbinjhade

@piyushbinjhade piyushbinjhade commented Dec 6, 2026 •

Copy link
Copy Markdown

Fixes #1942

Exports mapErrorCodeToStatusCode(code) so custom reject implementations
can reuse the built-in error code to status code mapping.

  • The default reject now uses the helper; its behaviour is unchanged.
  • The helper only looks up own properties, so codes like "constructor"
    return undefined.
  • Added unit tests and a docs example under "Handling errors".

Testing:

  • npm test in packages/rest: 635 passing, 2 pending
  • Prettier and ESLint pass on the changed files
  • Checked that the docs example compiles in examples/todo

Checklist

  • DCO (Developer Certificate of Origin) signed in all commits
  • npm test passes on your machine
  • New tests added or existing tests modified to cover all changes
  • Code conforms with the style guide
  • API Documentation in code was updated
  • Documentation in /docs/site was updated
  • Affected artifact templates in packages/cli were updated
  • Affected example projects in examples/* were updated

Signed-off-by: piyushbinjhade <piyushbinjhade2019@gmail.com>
@piyushbinjhade

Copy link
Copy Markdown
Author

I've opened a PR for this: #11942

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enable custom reject implementation to leverage the built-in "code to statusCode" mapping

1 participant