3 ms·
Yeah it lets you put code that goes in "catch" all over your function body, right next to where it's most relevant. It lets you go "hm but what about errors? ah
by skrebbel 1y ago
Yeah it lets you put code that goes in "catch" all over your function body, right next to where it's most relevant. It lets you go "hm but what about errors? ah handled! ok i can forget about it" when reading a function without having to skip back and forth between the main code and the catch block.
- jayd16 1y agoBut that's just try blocks around where it's relevant except the more precise scoping of a block and the catch being after where the errdefer is before.
- masklinn 1y ago> Yeah it lets you put code that goes in "catch" all over your function body, right next to where it's most relevant. To be fair I’ve rarely seen that, usually you’ve got half the method in a giant try block and have fun untangling which errors are caught intentionally and which are side-effects.