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

Handle subapps errors on parent app #299

Closed
gabrielcursino opened this issue Jul 30, 2021 · 0 comments · Fixed by #362
Closed

Handle subapps errors on parent app #299

gabrielcursino opened this issue Jul 30, 2021 · 0 comments · Fixed by #362
Labels
core Affects `@tinyhttp/app` - the tinyhttp core enhancement New feature or request

Comments

@gabrielcursino
Copy link

Is your feature request related to a problem? Please describe.
If an error occurs on subapp parent app orError is not called

Describe the solution you'd like
Handle subapps errors on parent app

Describe alternatives you've considered
As workaround i am exporting parent options:

...
export const options = {
  onError: (err: any, _: Request, res: Response) => {
    res.status(err.status ?? 500).json({ message: err?.message ?? 'Ocorreu um erro' });
  }
};
...

And importing it to use in subapps:

import { app, options } from '../services/app';

const Controller = new App(options);
...

Is there a better way to do this or some way of parent app handle subapps errors?

@gabrielcursino gabrielcursino added the enhancement New feature or request label Jul 30, 2021
@talentlessguy talentlessguy added the core Affects `@tinyhttp/app` - the tinyhttp core label Aug 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Affects `@tinyhttp/app` - the tinyhttp core enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants