Is there a way to annotate a method so all exceptions thrown are converted to runtime exception automagically?
@MagicAnnotation
// no throws clause!
void foo()
{
throw new Exception("bar")'
}
Project Lombok's @SneakyThrows
is probably what you are looking for. Is not really wrapping your exception (because it can be a problem in a lot of cases), it just doesn't throw an error during compilation.
@SneakyThrows
void foo() {
throw new Exception("bar")'
}