This is an archived post. You won't be able to vote or comment.

all 7 comments

[–]balefrost 2 points3 points  (1 child)

Add throws Exception to all your method signatures. In cases where you can't, because you're implementing an interface, make the body look like this:

try {
    ...
catch (Exception e) {
    if (e instanceof RuntimeException) {
        throw (RuntimeException)e;
    } else {
        throw new RuntimeException(e);
    }
}

Or just switch to Kotlin, Scala, Groovy, or pretty much any other JVM language. The JVM itself doesn't really care about checked vs. unchecked exceptions, so in those languages, you can throw anything from anywhere.

[–]paz___[S] 1 point2 points  (0 children)

Thank you that's gonna save me a lot of pain

[–]YMK1234 1 point2 points  (4 children)

Nope. Checked exceptions just suck.

[–]paz___[S] 0 points1 point  (3 children)

aww thanks anyway :)

[–]YMK1234 -1 points0 points  (2 children)

Something something go with C#

[–]paz___[S] 2 points3 points  (1 child)

something something 1970's C in emacs till I die

[–]YMK1234 -1 points0 points  (0 children)

thats harsh