Improving handling of error responses