-
-
Notifications
You must be signed in to change notification settings - Fork 137
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
Some suggestions on error handling #612
Comments
Hi @viert Sorry for the late reply, I needed to think about this.
Thanks!
The best way to do this would be to override the class class ErrorHttpResponse extends HttpResponseClientError {
constructor(readonly statusCode: number, body?: any, options: { stream?: boolean } = {}) {
super(body, options);
}
} Overriding
A PR is on its way. It will be possible to disable error logging with the configuration key |
Great stuff, thanks! |
Version 1.7 published. Configuration |
Thanks for the fantastic framework!
I'd like to suggest some improvements which are not supposed to change the overall architecture but could improve UX of error handling.
In most cases the most of the work happens in services. If a service fails to do something (find an object in db, parse user input, etc.) the fastest way to stop doing anything and return an error is to throw an Error from the service, so the error handler could catch it and provide a proper response.
That's how I deal with it:
So far so good I have implemented this and created an error handler behaving like this:
So, to the suggestions:
I'd like to instantiate a HttpResponse object accepting statusCode as a param. Right now I have to create
new HttpResponseOK
and change its statusCode afterwards. I haven't found any classes providing this behavior and HttpResponse itself is an abstract class which can't be instantiated.I'd like to have a possibility to suppress logging these exceptions as they are a part of my application, thus, properly handled and may not need to be automatically logged (with a full stack trace).
The text was updated successfully, but these errors were encountered: