question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItĀ collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Documentation on expected errors payload?

See original GitHub issue

I’m running into an issue where my errors response is not as I expect, but I can’t find any documentation on what the expected format is supposed to be.

Currently, my errors response is formatted like this (JSONAPI spec, I guess):

{
  errors: [
    "Error message"
  ]
}

But the error response from my ajax request makes it look like an array of objects.

screen shot 2016-05-11 at 4 28 36 pm

I really just don’t know how I am supposed to work with the errors object because I can’t find any documentation about it.

this.get('ajax').post('endpoint', payload).then(success).catch(function(e){
  console.error("errors", e.errors); // looks like an array of objects
  console.error("messages", e.errors.messages); // undefined
  console.error(e.errors.join('. ')); // [Object object].
});
``

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:4
  • Comments:18 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
alexlafrosciacommented, May 14, 2016

@wasabigeek I’ll make sure to cover that in my documentation. The best approach would be to make your own sub-class of the ajax service (so, make your own service, import the AjaxService and extend from that) and then overwrite the normalizeErrorResponse method to do something like this (no guarantees that this exact code would work, though; this is just off the top of my head)

normalizeErrorResponse(status, headers, payload) {
  if (Ember.isArray(payload.errors)) {
    return payload.errors.map(function(error) => {
      return { detail: error };
    });
  }
}

This should set things up so that the AjaxError class receives the format that it’s expecting.

If there’s any suggestions on how we could make this easier, I would love to hear them! The idea is for ember-ajax to be extensible for exactly this purpose, and I realize the docs aren’t great right now. I’m working on it!

0reactions
chrismcommented, Jun 13, 2016

In which case that sounds perfect to me šŸ‘

Read more comments on GitHub >

github_iconTop Results From Across the Web

Exception payload / error handling - Google Groups
I am asking since I would expect different types of clients to handle one format better than another. For instance, I don't expect...
Read more >
Error message contains whole payload when the type is not ...
I tried to send (wrongly) a string using POST /indexes/x/documents . The returned error message from MeiliSearch is as follows:
Read more >
Troubleshooting payload deployment issues
Error occurs when you run arpayloaddeploymentutil.bat. The status of Deployment Payload entries is stuck in Waiting For Utility Run.
Read more >
Error handling - Apollo GraphQL Docs
Making errors actionable on the client and server Ā· Built-in error codes Ā· Custom errors Ā· Throwing errors Ā· Omitting or including stacktrace...
Read more >
Mule Errors | MuleSoft Documentation
You can then gain access to error message attributes (metadata) and to the payload itself with #[error.errorMessage.payload] for the payload and #[error.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found