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.

Promise should return full error object

See original GitHub issue

Hi, Currently this package return error.response when promise fails https://github.com/spatie/form-backend-validation/blob/master/src/Form.js#L173

But i want to leverage axios error object, see how https://github.com/mzabriskie/axios#handling-errors

We should return full error object so the developer can fully utilize it.

.catch((error) => {
                    this.processing = false;
                    this.onFail(error.response.data);
                    // return error not just response
                    reject(error);
 });

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
sidouglascommented, Aug 21, 2017

If there is a network timeout, that error object won’t have a response property, and it’s going to crash any return with a type error. I’m running into this now.

.catch((error) => {
                    this.processing = false;
                    if(error.hasOwnProperty('response')){
                     this.onFail(error.response.data); //the data or undefined.
                    }
                    // return error not just response
                    reject(error);
 });
0reactions
sebastiandedeynecommented, Aug 21, 2017

The minute Laravel 5.5 is officially released, so some time next week 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error handling with promises
In the task an error is thrown form inside the promise and promise is never settled neither with a resolve nor reject. The...
Read more >
Promise.prototype.catch() - JavaScript - MDN Web Docs
The catch method is used for error handling in promise composition. Since it returns a Promise , it can be chained in the...
Read more >
Promise Error Handling
In this tutorial, you will learn about promise error handling that shows you how to handle error in promises.
Read more >
javascript - How do I handle errors with promises?
myFn(param).then(function(calcN){ // here, you throw to raise an error and return to resolve // new Promise should be used only when ...
Read more >
JavaScript Promises – The promise.then, promise.catch ...
then : when a promise is successful, you can then use the resolved data · catch : when a promise fails, you catch...
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