zooniverse / json-api-client

Apache License 2.0
10 stars 5 forks source link

improve API error handling #36

Closed mcbouslog closed 7 years ago

mcbouslog commented 7 years ago

PLEASE EDIT THIS INITIAL COMMENT AS YOU SEE FIT

Issue: to handle api errors from json-api-client better.

Before SGL (1st PRs):

  1. update json-api-client to return error object (with status and response fields) - PR #37
  2. update panoptes-client to return error object (with status and response fields) - panoptes-client PR #62

If Possible Before SGL (2nd PRs):

  1. bump json-api-client superagent version to 1.8.2, use native superagent Promise

After SGL (other PRs):

  1. combine json-api-client and panoptes-javascript-client
eatyourgreens commented 7 years ago

Errors should be coming back as simple objects in the response body. http://jsonapi.org/format/#errors I think the Panoptes JavaScript client is swallowing those responses, instead of passing them to the client app.

eatyourgreens commented 7 years ago

Related discussion in #27 too.

mcbouslog commented 7 years ago

@eatyourgreens - is the error.response.body.errors array from the superagent error object (screen shot below) what you mention above or are you referring to what the jsonapi docs note - "Error objects MUST be returned as an array keyed by errors in the top level of a JSON API document?" I'm not sure I entire understand what that is stating.

A. Is there an API request I could do to test what multiple errors would look like? B. Are there other common errors and their related requests I can try? C. The jsonapi docs list things the error object "MAY" have. Do the attributes of error.response suffice? They're not labeled exactly the same, but they appear to provide similar if not the same information.

screen shot 2017-03-14 at 3 25 40 pm

mcbouslog commented 7 years ago

I'm thinking we replace this issue with separate, more specific issues, as we continue to make improvements to this client and the panoptes-javascript-client.