Properly handle error responses