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

gateway-express, when the underlying seneca throws, should pass the error to Express #1

Open
lilsweetcaligula opened this issue Sep 14, 2021 · 2 comments

Comments

@lilsweetcaligula
Copy link
Contributor

lilsweetcaligula commented Sep 14, 2021

https://github.com/senecajs/seneca-gateway-express/blob/main/src/gateway-express.ts#L23

When this issue is addressed, then the user's Express error handler will be able to run as normal. Otherwise it is impossible to handle errors without resorting to sorcery.

@lilsweetcaligula
Copy link
Contributor Author

lilsweetcaligula commented Sep 14, 2021

Currently, whenever a Seneca instance throws an error that I would like to handle, I cannot do that. For example, in my Express app, I would like to catch all act_not_found errors and respond with 404 HTTP. Instead when I send a request to my app, like so:

$ curl $LOCALHOST:9000/api -d '{ "hello": "world", "does": "not_exit" }' -H 'content-type: application/json'

I get 200 HTTP and a payload like this:

{
  error$: true,
  seneca$: true,
  code$: 'act_not_found'
}

@kierandesmond
Copy link

Maybe with custom error handling (middleware) you could intercept the Seneca errors and handle them accordingly. 404 response makes sense.

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

No branches or pull requests

2 participants