A
A
Arthur Politiko2018-08-26 01:05:39
JavaScript
Arthur Politiko, 2018-08-26 01:05:39

How to call throw new SubmissionError from a Promise?

Good time everyone.
Tell me how you can call throw new SubmissionError from Promise ?
As soon as it was not perverted, instead of actions that usually occur in synchronous code when calling throw new SubmissionError , in asynchronous code a line like this is displayed in the console: Uncaught (in promise) .
Something like this:
In the component class

err = (error) => {
      throw error;
  }

 submit(values) {
...
    let p = new Promise(resolve => {setTimeout(resolve, 3000, new SubmissionError({time: 'Измените период', _error: "Login failed!", }))});
    p.then(result => this.err(result));
...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
msdosx86, 2018-08-26
@msdosx86

new Promise ((resolve, reject) => reject(new Error());
Then catch in catch

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question