News for hackers. Stuff that matters.

flimzy

Re:Error handling in Go web apps shouldn't be so awkward on Wednesday January 10, 2024 @09:55AM (#38939538)
Post author here.

For any non-trivial app, there would ideally be a set of domain error types/codes that the various application layers know about, rather than concerning themselves with HTTP statuses.

I didn't discuss that in the article, because I felt like it was a bit tangential. Perhaps it was a mistake to omit that detail.

Re:Error handling in Go web apps shouldn't be so awkward on Wednesday January 10, 2024 @09:54AM (#38939526)
Post author here.

I probably could have made this a bit more clear, but I feel it was a slight tangent to the main point of the post: In any serious app, I wouldn't actually set an HTTP status directly in the db layer. Rather, I would do what others in this thread have suggested: I'd have a set of domain error types/codes, and my DB layer would set _that_.

That domain error value would then implement the `HTTPStatus()` method to return the appropriate status code.

This allows you to have multiple "not found" error codes (as an example) for internal use, which all resolve to an HTTP status of 404.

Re:TeamTopologies on Friday July 28, 2023 @09:19AM (#36906360)
"having been on one" -- So n of 1.

Classic "my experience trumps yours".