←back to thread

517 points bkolobara | 1 comments | | HN request time: 0s | source
Show context
aeve890 ◴[] No.45042188[source]
>The code will compile just fine. The Zig compiler will generate a new number for each unique 'error.*'

This is wild. I assume there's at least the tooling to catch this kind of errors right?

replies(3): >>45042403 #>>45042586 #>>45050319 #
TUSF ◴[] No.45042403[source]
There's no special tooling to catch this, because nobody catches an error with if-else—it's simply not idiomatic. Everyone uses switch statements in the catch block, and I've never seen anybody using anything other than switch, when catching an error.
replies(4): >>45042474 #>>45042605 #>>45043295 #>>45043644 #
arwalk ◴[] No.45042605[source]
The real problem is not about the if-else, its that he's comparing to the global error set, and not to the FileError error set he created specifically to define AccessDenied.
replies(1): >>45043300 #
1. love2read ◴[] No.45043300[source]
The real problem is that this compiles without error