Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Looking for some ideas how to have errors transit decoupled parts #377

Open
wvh opened this issue Oct 1, 2020 · 0 comments
Open

Looking for some ideas how to have errors transit decoupled parts #377

wvh opened this issue Oct 1, 2020 · 0 comments

Comments

@wvh
Copy link

wvh commented Oct 1, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant