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
I'm going through some of the more advanced topics in the book about testing decoupled parts and while the examples are clear, I'm always running into difficulties when I have to translate errors between layers. For example, if a database query indicates the requesting user doesn't have access, or something doesn't exist or exists already, or the database went away, and these errors would need to be reflected in HTTP API status codes. These errors would somewhat break the decoupling.
I tend to use application-wide errors, but it's not always a satisfactory solution to create an error package that all components then need to import. I've also used gigantic switch statements to convert errors from one layer to the other. I was wondering if there are some other ideas on how to solve these sorts of problems without ending up with error handling code that couples for instance database and HTTP layers quite strongly.
Thanks for the concrete examples, it's interesting to see how others link components together in idiomatic fashion. Information on how to architect larger software projects in Go is pretty scarce.
The text was updated successfully, but these errors were encountered:
Hello,
I'm going through some of the more advanced topics in the book about testing decoupled parts and while the examples are clear, I'm always running into difficulties when I have to translate errors between layers. For example, if a database query indicates the requesting user doesn't have access, or something doesn't exist or exists already, or the database went away, and these errors would need to be reflected in HTTP API status codes. These errors would somewhat break the decoupling.
I tend to use application-wide errors, but it's not always a satisfactory solution to create an error package that all components then need to import. I've also used gigantic switch statements to convert errors from one layer to the other. I was wondering if there are some other ideas on how to solve these sorts of problems without ending up with error handling code that couples for instance database and HTTP layers quite strongly.
Thanks for the concrete examples, it's interesting to see how others link components together in idiomatic fashion. Information on how to architect larger software projects in Go is pretty scarce.
The text was updated successfully, but these errors were encountered: