refine the exception handle