4 ms·
try/catch can be as much as verbose try { foo(); val = bar(); baz(); } catch (Exception $e) { // all lumped together, n
by tored 5y ago
try/catch can be as much as verbose
try {
foo();
val = bar();
baz();
} catch (Exception $e) {
// all lumped together, not good
}
try {
foo();
val = bar();
baz();
} catch (RangeException $e) {
// who is throwing what?
} catch (NotFoundException $e) {
// who is throwing what?
} catch (SomeOtherException $e) {
// who is throwing what?
}
try {
foo();
} catch (SomeOtherException $e) {
// very verbose
}
try {
val = bar();
} catch (NotFoundException $e) {
// very verbose
}
try {
baz();
} catch (RangeException $e) {
// very verbose
}
- vips7L 5y agoThat’s only if you’re actually handling your exceptions. The author of the post isn’t handling errors he’s just propagating. When just propagating, exceptions have no verbosity: foo(); bar(); baz();
- masklinn 5y agoI don’t think “in the worst case scenario imaginable exceptions are as verbose as Go’s baseline” is much of a slam dunk.
- daoman 5y agoWow, that's an excellent illustration!