News for hackers. Stuff that matters.
Re:Twelve Years of Go by grey-area on Wednesday November 10, 2021 @03:18PM (#29180105)
Your users typically don't want the program to crash, spare a thought for them.

Re stack traces, they're fine I guess, but I prefer a well-crafted error message to 200 lines of irrelevant file locations/functions.

Re:Twelve Years of Go by JoeyJoJoJr on Wednesday November 10, 2021 @03:53PM (#29180609)
I want my program to crash obviously during development so that I know of the existence of bugs, which can be ironed out before getting to production.
Re:Twelve Years of Go by grey-area on Wednesday November 10, 2021 @04:01PM (#29180724)
That's the theory.

In practice it's impossible to exercise all the inputs your programs may get, and then they crash in production when users do things you don't expect.

Re:Twelve Years of Go by kaba0 on Wednesday November 10, 2021 @04:50PM (#29181405)
Which is better than having a bug silently be in production for years to come due to a silent error.
Re:Twelve Years of Go by grey-area on Thursday November 11, 2021 @01:59AM (#29185223)
Which is worse than just handling the error where it occurs.
Re:Twelve Years of Go by kaba0 on Wednesday November 10, 2021 @04:49PM (#29181400)
That’s the point of exceptions. They bubble up! I can manage them at a place where it is appropriate.

Something had happened during the processing of this web request? Catch the exception and convert it to an appropriate status code.

You should only ever let exceptions fall through ”main” when the problem is really not something you can manage to handle.

Re:Twelve Years of Go by grey-area on Wednesday November 10, 2021 @05:02PM (#29181531)
That's the theory.

In practice often people let the exception eater in main handle it, and it either logs somewhere nobody looks or returns this sort of generic error and exits:

https://www.google.com/search?q=Microsoft+Word+has+encounter...