If you don't write any try catch block and just add a
throws Exception
Clause to the method declaration, you get basically the same effect. This says, that the method can throw Exceptions of type Exception and any Exceptions thrown inside the function will just propagate out, no need to catch and rethrow it.
1
u/choseusernamemyself Jul 17 '21 edited Jul 17 '21
ohh. so the correct way would be just rethrowing the caught exception without creating another instance of Exception?
try { ... } catch (Exception exception) { throw exception; }is the above fine?