Добавлено: 26 февраля 2023 г.
Error handling with Async/Await in JS
This will be a small article, based on some issues I picked up during code reviews and discussions with other developers. This article is rather focused on the novice JS developers.
A Simple Try Catch
Let’s start with the simple try...catch example.
function thisThrows() {
throw new Error("Thrown from thisThrows()");
}
try {
thisThrows();
} catch (e) {
console.error(e);
} finally {
console.log('We do cleanup here');
}
// Output:
// Error: Thrown from thisThrows()
// ...stacktrace
//...
далее...
Добавлено: 12 марта 2021 г.
Exceptions are part of any software and can happen any time even where we are absolutely sure that nothing can go wrong. Exceptions are inevitable, we all agree with that. We should always deal with them in our applications to avoid any kind of unrecoverable crash.
In order to avoid any chaotic scenario that could happen, we should handle our exceptions in a way that could help us deal with the...
далее...