Refine the error handling.