Google's own REST APIs return detailed response in case of an error, e.g:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "invalidBookshelfId",
"message": "Invalid bookshelf ID."
}
],
"code": 400,
"message": "Invalid bookshelf ID."
}
}
In Google Cloud Endpoints for Python, it's possible to e.g. raise endpoints.BadRequestException('Error message'), but in addition to the error message I would like to return "code" or "reason" as in example above. Is there any way to achieve this?
The code corresponds to the status code associated with BadRequestException. The other exceptions are documented as well, for example endpoints.UnauthorizedException corresponds to the status code 401. As for the reason and the domain, those are set by Google's API Infrastructure.
What did you have in mind that isn't possible to set in message?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With