Improved error handling for BadResponseException