#Where to handle errors?

1 messages · Page 1 of 1 (latest)

tacit rose
#

Should rest service errors be handled in the service itself via state signals that can be accessed by components, or from within components themselves via the classic isLoading/isError combo?

heavy finch
#

There are various kinds of services, and the answer very much depends on which kind of service you're writing. The code matters.

tacit rose
#

It's a rest server service. Right now I'm handling the errors in the service and "notifying" components via signals (using the signals in template conditionals to render the loading/error messages)

heavy finch
#

I have no idea how you coded, provided and used this rest server service. And all those details matter.

undone helm
#

REST API's Error's should always be handled on the compoent level just write a common error handler function and call it there

misty quail
#

Another approach would be to centralize error handling of your Rest API using an http interceptor. Since it’s a cross-cutting concern