verloop / twirpy

Twirp's python implementation
The Unlicense
104 stars 21 forks source link

Bugfix: Return proper error #27

Closed avinassh closed 3 years ago

avinassh commented 3 years ago

client side errors were not getting properly mapped to the Twirp errors and defaulting to the Unknown error

return any error from the server and client will print as unknown

When response status is not 200, we generate an error calling TwirpServerException.from_json, to this method, we send the error code as strings like invalid_argument or permission_denied. If you check TwirpServerException's constructor, it sorta expects code to be of error.Errors instance, if not, it defaults to Errors.Unknown error.

ofpiyush commented 3 years ago

The server exception implementation is wrong, it's supposed to check if the code is one of the available enum values only, not an instance