Fix a bug in exception handling.