Answer the question
In order to leave comments, you need to log in
How to return an error in a promise?
What should I return inside the check3 function so that the execution of the code immediately jumps to the catch block ?
By immediately, it means jumping to catch without subsequently executing the check4 and check5 functions .
async function sequence() {
try {
await check1();
await check2();
await check3();
await check4();
await check5();
return {
'success': true,
'message': 'Проверка прошла успешно.'
};
}
catch(err) {
return {
'success': false,
'message': 'Ошибка: ' + err
};
}
}
async function check3() {
return ???;
}
Answer the question
In order to leave comments, you need to log in
Do not return - discard)
const check3 = () => {
if (true) {
throw "Че-т не получилось";
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question