You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The motivation for this proposal comes from the error handling in the middleware.
I tried to create a middleware that only logs specific errors, but I had to parse the error message to distinguish whether the "internal_server_error" was a DB error or some other unexpected error, and so on.
I am thinking that if the original error is embedded in ServiceError, it would be possible to distinguish the error by error type without having to parse the error message.
TL;DR;
A field is added to ServiceError to hold the error and the Unwrap interface is implemented.
The generated helper functions (MakeXXXX) wraps the error.
The original error is embedded or attached in ServiceError, making it easier to handle errors with errors.Is() and errors.As().
PoC
PoC 1: Add a field to the ServiceError structure to hold the error
I have written another PoC to see if I could handle this by adding new helper functions without modifying the core Goa structures. This method does not affect existing user code.
Motivation
The motivation for this proposal comes from the error handling in the middleware.
I tried to create a middleware that only logs specific errors, but I had to parse the error message to distinguish whether the "internal_server_error" was a DB error or some other unexpected error, and so on.
I am thinking that if the original error is embedded in ServiceError, it would be possible to distinguish the error by error type without having to parse the error message.
TL;DR;
PoC
The text was updated successfully, but these errors were encountered: