Hacker News new | past | comments | ask | show | jobs | submit login

I'm only saying what I've seen here. I typically see praise for Rust's checked errors. Especially since they provide ? to panic and uncheck them. Personally I disagree with Bloch, if you are the thrower you can't possibly know if the caller can or cannot recover from your error so in my opinion its best to check it. If you are not the thrower and you can't recover from it I prefer to uncheck them, because if I can't recover my caller most likely can't either.

The issue really just arises with Java not giving you the capability to uncheck that error easily if you can't recover from it. For example, you need a ton of lines to uncheck:

    A doIt() throws B {
       throw new B();
    }

    void usingIt() {
       A a;
       try {
           a = doIt();
       } catch (B b) {
           throw new RuntimeException(b);
       }
       
       a.woohoo();
    }

My ideal situation would be for some sort of throws unchecked operator (or whatever syntax we want to bikeshed over) that turns them into unchecked exceptions.

    void usingIt() throws unchecked B {
        var a = doIt();
        a.woohoo();
    }





Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: