Comment

Comment by tored

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
    }
parent tored 5 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton