I'd like to create a routine that does some logging, takes some other actions, and then throws an Exception. I'd like this routine to be called from many different locations. However, creating Exceptions in this routine means they will have this routine in their stack trace. I would rather the stack trace not report this utility routine. Is there a way to do this without creating the Exception in the caller and passing it to the utility routine?
public static void die(String message) throws MyException {
log(message);
...
throw new MyException();
}
For programmers who are Perl/Java bilingual: how do I carp in Java?