You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@sumn2u has made changes on the original english version of the book (PR #254)
Visual Diff of Changes:
diff --git a/en/SUMMARY.md b/en/SUMMARY.md
index 87df426..ab6b8ab 100644
--- a/en/SUMMARY.md+++ b/en/SUMMARY.md@@ -73,6 +73,7 @@
- [Error Handling](error-handling/README.md)
- [Try...Catch](error-handling/try...-catch.md)
- [Try...Catch...Finally](error-handling/try...catch...finally.md)
+ - [Asynchronous Error Handling](error-handling/async_errorhandling.md)
- [Modules](modules.md)
- [Regular Expression](regular-expression.md)
- [Classes](classes/README.md)
diff --git a/en/error-handling/README.md b/en/error-handling/README.md
index e79981e..ad8122e 100644
--- a/en/error-handling/README.md+++ b/en/error-handling/README.md@@ -58,8 +58,10 @@ One of the common error handling techniques is the `try...catch` block, which is
* [try...catch](./try...-catch.md)
* [try...catch...finally](./try...catch...finally.md)
-Error handling is a critical aspect of JavaScript development.-By understanding the types of errors, and following best practices, -you can write more reliable and user-friendly applications.+## Asynchronous Error Handling++Handling errors in asynchronous code can be tricky. In synchronous code, errors are caught immediately, but with asynchronous operations like API calls, errors may occur later. You'll handle them in callbacks or promises, so you need to be prepared. We'll cover how to manage these errors using promises and `async/await` in the section below.++* [Asynchronous Error Handling](./async_errorhandling.md)diff --git a/en/error-handling/async_errorhandling.md b/en/error-handling/async_errorhandling.md
index 9f4a245..0423aa9 100644
--- a/en/error-handling/async_errorhandling.md+++ b/en/error-handling/async_errorhandling.md@@ -1,4 +1,7 @@-+---+chapter: 12+pageNumber: 87+description: Handling asynchronous errors is a bit more complex than synchronous errors. The issue is that the code that generates the error is not directly responsible for handling the error. Instead, the error will be handled by the callback function that is executed when the asynchronous operation is complete.
---
# Asynchronous Error Handling
@@ -10,7 +13,7 @@ The example below shows how you can handle asynchronous errors:
A common example is when using the `fetch` API to download some data from a server. The `fetch` API returns a promise that resolves with the server response. If the server returns an error, the promise will reject with the error.
-### Example 1: Using `try...catch` with `async/await`+#### Using `try...catch` with `async/await`
Using `async/await` makes asynchronous code look and behave more like synchronous code, which can make it easier to read and understand. Here's how you can handle errors using `try...catch`:
@@ -30,7 +33,7 @@ async function fetchData(url) {
-### Example 2: Handling errors with .catch() in Promises
+#### Handling errors with .catch() in Promises
When using Promises directly, you can handle errors using the .catch() method:
@@ -91,7+94,7 @@ asyncfunctionfetchData(url){
-### Graceful Degradation: Provide fallback behavior or user-friendly error messages.
+#### Graceful Degradation: Provide fallback behavior or user-friendly error messages.
-### Avoid Silent Failures: Ensure that errors are not swallowed silently; always log or handle them.
+#### Avoid Silent Failures: Ensure that errors are not swallowed silently; always log or handle them.
Proper error handling in asynchronous operations is crucial for building resilient JavaScript applications. By following the examples and best practices outlined in this guide, you can ensure that your code gracefully handles errors, provides meaningful feedback to users, and maintains overall application stability. Always remember to handle errors in every asynchronous operation, use try...catch with async/await for readability, and implement centralized error handling for larger applications. With these strategies, you can effectively manage asynchronous errors and create more reliable and user-friendly applications.
The text was updated successfully, but these errors were encountered:
@sumn2u has made changes on the original english version of the book (PR #254)
Visual Diff of Changes:
-### Example 2: Handling errors with
.catch()
in Promises+#### Handling errors with
.catch()
in PromisesWhen using Promises directly, you can handle errors using the
.catch()
method:-### Graceful Degradation: Provide fallback behavior or user-friendly error messages.
+#### Graceful Degradation: Provide fallback behavior or user-friendly error messages.
-### Logging: Log errors for debugging and monitoring purposes.
+#### Logging: Log errors for debugging and monitoring purposes.
-### Avoid Silent Failures: Ensure that errors are not swallowed silently; always log or handle them.
+#### Avoid Silent Failures: Ensure that errors are not swallowed silently; always log or handle them.
-## Conclusion
Proper error handling in asynchronous operations is crucial for building resilient JavaScript applications. By following the examples and best practices outlined in this guide, you can ensure that your code gracefully handles errors, provides meaningful feedback to users, and maintains overall application stability. Always remember to handle errors in every asynchronous operation, use try...catch with async/await for readability, and implement centralized error handling for larger applications. With these strategies, you can effectively manage asynchronous errors and create more reliable and user-friendly applications.
The text was updated successfully, but these errors were encountered: