JsonApiClient / json_api_client

Build client libraries compliant with specification defined by jsonapi.org
MIT License
362 stars 186 forks source link

Rework Errors::NotFound #393

Closed lannon closed 2 years ago

lannon commented 3 years ago

We don't currently pass the Faraday environment when raising a NotFound exception in the Status middleware. This is inconsistent with other types of errors that inherit from ApiError and causes us to lose any JSON API errors that might be present in the environment.

This change reworks the NotFound exception constructor such that it accepts a Faraday::Env and an optional message. If an environment is passed and a msg is not, it sets a message using environment[:url] to maintain previous messaging. However, it passes along the environment to the super call such that we can supplement the messaging with the JSON API error message handling implemented on ApiError.

If the first argument provided to the constructor is anything other than a Faraday::Env, then the previous behavior is provided.