More generic exception handler