-
Notifications
You must be signed in to change notification settings - Fork 34
Description
For example, this gets thrown as SparkPostErrorServerResponseException:
SEVERE: Error reading server response: { "errors": [ { "message": "Message generation rejected", "description": "recipient address suppressed due to customer policy", "code": "1902" } ], "results": { "total_rejected_recipients": 0, "total_accepted_recipients": 1, "id": "84509310299791535" } }(Bad Request)
..which is not really developer friendly. Basically, when exceptions for responses like 4XX are thrown the whole response body is concat to the exception message. If I want to get the internal error code (1902) to store it somewhere I need to first remove the "Error reading server response" from message, then write a custom POJO to parse the remaining body into it.
It would be way nicer if we could grab the error response body directly from SparkPostException as an object, not needing to parse the text message ourself. Or at least get the clean response text.
Right now the library basically hides the response body from us and I don't see any good way to retreive it other than the way mentioned above.