5 ms·
> No 'oops I forgot to put in a try/catch and now my code died with no explanation'. This is so backwards. First, I want my program to immediately crash if I h
by kbd 5y ago
> No 'oops I forgot to put in a try/catch and now my code died with no explanation'.
This is so backwards. First, I want my program to immediately crash if I have a bug. Go is like shell in that it keeps going even if there's an error. Second, I'm used to getting stack traces, Go is the language that will give "no explanation" by comparison if there's a failure.
- nineplay 5y agoI don't know what scale of projects you've worked on. When you're dealing 100K requests/second you very much do not want to immediately crash. It is absolutely the worst think your code can do.
- kaba0 5y agoWhat framework, language crashes due to an exception, regardless of scale? That exception gets mapped to a http status code and that gets returned.
- grey-area 5y agoYour 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.
- JoeyJoJoJr 5y agoI 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.
- grey-area 5y agoThat'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.
- kaba0 5y agoThat’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.
- grey-area 5y agoThat'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+encountered+a+problem+and+needs+to+close https://www.google.com/search?q=Microsoft+Word+has+encounter...
- vlunkr 5y ago> First, I want my program to immediately crash if I have a bug. An error being returned doesn't always mean there's a bug. > Go is like shell in that it keeps going even if there's an error. With both Go and shell scripts it's up to you if you want the program to keep going when there's an error.
- kbd 5y ago> An error being returned doesn't always mean there's a bug. The bug is not the error, the bug is the unhandled error.