Error being logged even though it has been handled


I’m querying my express backend and if the item is not found it returns a jsonapi formatted error:

res.send({errors:[{status:404,title:'item not found'}]});

I don’t set a 4xx status on the response to avoid getting an error logged on the console. I changed the adapter to handle this type of errors by overriding isSuccess method:

isSuccess (status, headers, payload){
    return payload.errors === undefined;

But an additional error is being logged:

Error: Ember Data Request GET http://localhost:3000/products/query returned a 200
Payload (application/json; charset=utf-8)
[object Object]
at new Error (native)
at Error.EmberError (http://localhost:4200/assets/vendor.js:29816:21)
at Error.AdapterError (http://localhost:4200/assets/vendor.js:84679:16)
at Class.handleResponse (http://localhost:4200/assets/vendor.js:85956:14)
at Class.hash.success (http://localhost:4200/assets/vendor.js:86020:34)
at fire (http://localhost:4200/assets/vendor.js:3499:31)
at Object.fireWith [as resolveWith] (http://localhost:4200/assets/vendor.js:3629:7)
at done (http://localhost:4200/assets/vendor.js:9069:14)
at XMLHttpRequest.<anonymous> (http://localhost:4200/assets/vendor.js:9435:9)

How do I disable logging for these type of errors?


Hey the error response may need to be an object not and array like this:

res.send({errors:{status:404, title:'item not found'}});

also in the Adapters handleResponse method you can handle this error from happening by extracting the message from the array and then returning the error object. Ember doesn’t like the error in an array.


Hello, thank you for your reply.

I used an array because thats what is specified by the jsonapi website. I followed your advice and I’m still getting this error


Im using a rails backend but here is the format for my error messages and it doesnt throw an error.

render json: {errors: {msg: 'Unauthorized'}}

so you may want to try:

res.json({errors: {msg: "some message}});


Still getting the same error logged