#Problem with catching api exceptions

14 messages ยท Page 1 of 1 (latest)

south fossil
#

and thats method from an error service which I m using throuh interceptor to catch errors:

#

so at some point I have hard coded that code which I m getting from api

#

in that service

#

but it didnt helped

#

and thats the method with which I want to use

#

Im 100% sure that I have messed up in fe

lean beacon
#

Not sure, but seems like your handleError might catch HttpErrorResponse only.
In your case, it is not an HttpError (not an error during HttpClient process).

You can try something like

handleError(error: Error) {
        const errOrigine = error instanceof HttpErrorResponse ? 'Http Error (server)' : 'Other Error (client)';
        // your error processing logic
    }

https://angular.dev/api/core/ErrorHandler?tab=usage-notes

The web development framework for building modern apps.

south fossil
#

I m keep strugling with it

#

my endpoint returns of type FileStreamResult

#

but still excpetions thrown there are exact the same mapped for 400 badrequest like others

#

btw that error handler shouldnt be a service but rather a simple class?

south fossil
#

okay I m running in circles lol