govitia / navitia

A client library in Go for the Navitia API (navitia.io) (v2 WIP)
The Unlicense
6 stars 2 forks source link

Improve handling for remote error parsing failures. #10

Open aabizri opened 7 years ago

aabizri commented 7 years ago

The problem

Currently, when we try to parse a remote error, and its not a valid JSON payload, (such as some undefined errors and path errors) we return an error that is not a RemoteError, which also means that the specifics (status code & plain-text message) gets lost as well.

One solution

Add the ability to RemoteError to note what was the plain-text response in case the unmarshalling fails, such as a Plain []byte field noting the contents, an ID made on the fly, and correct RemoteError.Error handling.