Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix addError is undefined issues on Elysia 0.8.9 #2

Closed
wants to merge 1 commit into from
Closed

Fix addError is undefined issues on Elysia 0.8.9 #2

wants to merge 1 commit into from

Conversation

nathankleyn
Copy link
Contributor

Upgrade Elysia to 0.8.9 (latest):

$ bun pm ls
node_modules (19)
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
└── [email protected]

Then fix the breaking change to rename addError to error. After doing this there appears to be a bug where the custom error code is no longer set when the onError handler is called (code is always undefined); to work around this, use instanceof instead to check for the custom error code.

This fixes #1.

src/index.ts Outdated Show resolved Hide resolved
Upgrade Elysia to `0.8.9` (latest):

```
$ bun pm ls
node_modules (19)
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
└── [email protected]
```

Then fix the breaking change to rename `addError` to `error`. After
doing this there appears to be a bug where the custom error code is no
longer set when the `onError` handler is called (`code` is always
`undefined`); to work around this, use `instanceof` instead to check for
the custom error code.
@eelkevdbos
Copy link
Owner

@nathankleyn, thank you for your contribution! I'd like to go with the version supplied by @KilianB because it keeps the custom error code specification in tact. So I'm closing this for now, but again, much appreciated.

@eelkevdbos eelkevdbos closed this Feb 5, 2024
@nathankleyn
Copy link
Contributor Author

That's perfect, thanks so much @eelkevdbos — so appreciate this being fixed by both yourself and @KilianB! 👏 🙇‍♂️

@nathankleyn nathankleyn deleted the fix-adderror-is-undefined branch February 20, 2024 11:00
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.

addError is undefined when added as middleware to Elysia 0.8.9 project
3 participants