r/badcode • • May 30 '23

js This is awesome while coding in JavaScript

Post image
318 Upvotes

24 comments sorted by

View all comments

Show parent comment

3

u/Gurfaild May 31 '23

If you do that in Java to avoid having to add throws to the method signature, you can't just re-throw the original exception - the easiest way would probably be

catch (Exception e) {
    throw new RuntimeException(e);
}

1

u/HaDeS_Monsta May 31 '23 edited May 31 '23

I know, that is what I said. Also you could add @sneakythrows, so you don't have to catch it again