Ember data, jsonapi spec and errors

Hi all,

I am trying to return an error object from my api - for a situation, where for example there are no results returned for a query.

This is the type of error object I am returning:

 {"errors":[{"status":"422"}]}

This complies with recommendation set out in jsonapi.org spec (I hope!)

The error I get back from ember when I go to a page which will generate such an error is

Error: Assertion Failed: Expected an object in the 'data' property in a call to 'push' for undefined, but was undefined

Any ideas much appreciated!

Using Ember 2.4.2, Ember Data 2.4.0

Update:

for a query which returns no results, I am now returning the json object with basic info eg id and type - that work ok. However, I am still having a problem when, for example there is a problem with the database connection and you want to be returning the error object. I am still get

Assertion Failed: Expected an object in the ‘data’ property in a call to ‘push’ for undefined, but was undefined

This is the json I am responding with:

{"errors":[{"status":"422","detail":"Problem with the database connection"}]}

Did you ever figure this out? I’m also encountering the same issue. I want the error that I’m returning from the serializer to properly bubble up to route errors substate but instead is returning the ‘data’ property error.

A 422 response is intended for server-side validation errors when you create or update a resource. I think what you want to do is have your API return a 500 response since the error originated on the server.