4 ms·
Thanks! Hopefully 500 errors would never occur of course, but in that case I'd just return: { error: "Internal server error, please try again later" } There's
by thecodemonkey 13y ago
Thanks! Hopefully 500 errors would never occur of course, but in that case I'd just return:
{ error: "Internal server error, please try again later" }
There's not really a reason to give away anything else, it's usually because something is broken (database connection and whatnot) and the developers are probably already aware of it with tools such as Bugsnag[1] and alike.
In general for error messages, exceptions should be handled gracefully and output a simple message that is understandable for the user. It might also be ideal to include an error code with the JSON response if you have a lot of different error messages that happens under the same HTTP status code (e.g. 400 Client Error).
[1] https://bugsnag.com https://bugsnag.com
- jksmith 13y agoCool. Thanks for that. Yeah that's a good thing about golang. No exceptions (levity alert)! So it's always a message you get back unless somebody hit the panic button.