More general exception handling