osmlab / maproulette-python-client

MapRoulette Client Library for Python
https://maproulette-python-client.readthedocs.io
Apache License 2.0
11 stars 12 forks source link

[Feature Request] Provide message from API response in exception when relevant #56

Closed mattmanley closed 4 years ago

mattmanley commented 4 years ago

Is your feature request related to a problem? Please describe. At times, an exception will be raised with little to no context whereas the API response will contain some helpful information. For example, when trying to post a Challenge with a name that already exists in the database, our package would currently return:

maproulette.api.errors.HttpError: {'status': 500, 'message': 'An HTTP error occurred', 'payload': <Response [500]>}

However, the API response has message content containing:

{'Challenge with name Test_Challenge_Name already exists in the database'}

Ideally, we could include this message in our custom exception message, rather than the generic 'An HTTP error occurred'.

Describe the solution you'd like When present, the API response message should be returned to the user in the exception. If no message is present, we can use a default message.

Describe alternatives you've considered N/A

Additional context N/A