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
Today I have a scenario where my providers can return different errors when I have a problem to start the application.
Something like an A error for a failure to connect to the database and a B error for a problem connecting to redis.
I would like to centralize the handling of these errors in one place.
Think of something like an error handler that based on the error generates different logs and triggers other functions in go.
I tried to make a type assertion in an error handler but regardless of the source provider, the err object that arrives at the destination always has the same type (I believe because of this code).
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Today I have a scenario where my providers can return different errors when I have a problem to start the application.
Something like an A error for a failure to connect to the database and a B error for a problem connecting to redis.
I would like to centralize the handling of these errors in one place.
Think of something like an error handler that based on the error generates different logs and triggers other functions in go.
I tried to make a type assertion in an error handler but regardless of the source provider, the err object that arrives at the destination always has the same type (I believe because of this code).
What is the best way to handle errors using fx?
Beta Was this translation helpful? Give feedback.
All reactions