Rewrite exception handling.