by montyanderson on 5/21/24, 10:48 PM with 47 comments
by JodieBenitez on 5/22/24, 6:50 AM
Yes indeed.
> by writing custom messages, we can provide more details useful for debugging (for example, the os.ReadFile helped us with a filename);
Custom exceptions anyone ?
> by not relying on code line numbers, the messages are more long-lived, and can actually be understood and reasoned about in isolation, without access to the source code.
Doubt...
I quite like Go (some aspects of it anyway) and it's proven both useful and successful, but some people will go great length to find virtues in its weaknesses.
by acheong08 on 5/22/24, 4:07 AM
Check out https://github.com/rotisserie/eris. It really is a lifesaver
by steve_adams_86 on 5/22/24, 4:07 AM
Like many things in go, I think a lot of us unwittingly hope it will behave in familiar ways because so much of the language seems simple or intuitive. Unfortunately, without a good grasp on it, many parts of go will appear to cooperate with your hopes until it doesn’t.
I think a great example of this is the type system. There is a correct way to use it, but it’ll let you misuse it quite extensively before things start to implode. Errors are a bit like this. You can return raw errors for a long time and it’ll seem fine until suddenly, debugging and tracing issues is incredibly inconvenient and unintuitive.
I found the book “Learning Go” really helpful in breaking these bad habits and helping me get acquainted with how things actually work under the hood.
by vsnf on 5/22/24, 6:03 AM
by SebastianKra on 5/22/24, 10:28 AM
by LorenzoGood on 5/22/24, 3:47 AM
by samber on 5/26/24, 4:12 PM
by the_gipsy on 5/22/24, 8:45 AM
We wrap errors with stacktraces at library boundaries so that we can `return err` in most cases, unless we really want to add some information. But mostly we use sentry to push log messages with better data into breadcrumbs leading to the errors.
by jtohasdfasd on 5/22/24, 8:40 AM
This is much too burdensome for me to cognitively bear so I prefer a closed set model as seen in Zig, Rust, or any ML.
I don't recall if Swift has exhaustive error handling.
by feisuzhu on 5/22/24, 10:30 AM
by TheJCDenton on 5/22/24, 11:36 AM
by secretlyadog on 5/22/24, 3:02 AM
Though I suppose if this were another language it would be akin to a try catch around every line of code. Which in a way is great, but pretty labor intensive.
by doubloon on 5/22/24, 2:43 AM
by udev4096 on 5/22/24, 5:51 AM
by porjo on 5/22/24, 2:59 AM