her icon indicating copy to clipboard operation
her copied to clipboard

Processing JSON API Errors

Open chadwtaylor opened this issue 10 years ago • 4 comments

Following the JSON API documentation around errors (http://jsonapi.org/format/#errors-processing), what's the best way to handle that?

eg: p = Person.find(999) is expecting an error like so:

  {
    "errors": [
      {
        "status": "404",
        "detail": "Oh no, we could not find your friend!"
      }
    ]
  }

Instead, I'm receiving a nil. Is there a way to read the body of the response somewhere?

chadwtaylor avatar Aug 13 '15 23:08 chadwtaylor

I have the same question. Did you find a solution?

adamgotterer avatar Sep 05 '15 04:09 adamgotterer

what's the behavior you would expect here? you might be able to write a customized parser based on the JsonApiParser to do what you want.

hubert avatar Sep 07 '15 07:09 hubert

Likely to raise an exception or return an object that has the errors

adamgotterer avatar Sep 08 '15 01:09 adamgotterer

I'm having problems with this too. Since validations occur mainly on creating/updating to the database, I'm having trouble thinking about how to capture 404's when Her puts a GET request to a resource that doesn't exist. The code I work with sends back a 404 status, but I don't think Her is capturing that.

JasonEb avatar Oct 17 '15 00:10 JasonEb