From 5d2cdfd4ac7723ef4d9b45ced4fae133fd28ed6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sinan=20=C3=96zt=C3=BCrk?= Date: Mon, 12 Feb 2024 14:57:45 +0300 Subject: [PATCH] Update POST.md --- .../POST.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/docs/en/Community-Articles/2024-02-12-Global-Error-Handling-in-Angular/POST.md b/docs/en/Community-Articles/2024-02-12-Global-Error-Handling-in-Angular/POST.md index 41d8356aaf..5220c2ae5f 100644 --- a/docs/en/Community-Articles/2024-02-12-Global-Error-Handling-in-Angular/POST.md +++ b/docs/en/Community-Articles/2024-02-12-Global-Error-Handling-in-Angular/POST.md @@ -63,7 +63,7 @@ providers: [ ![toast-gif](show-toast-2.gif) -- It behaves the exactly the same. Nice, now we catch the entire errors in one simple service. +- It behaves exactly the same. Nice, now we catch the entire errors in one simple service. - Is it that simple? I wish it is but it's not 😀. This handling mechanism is only works synchronously. When we start to making http requests, our **`CustomErrorHandlerService`** wont catch the errors. ## How to handle HTTP Requests @@ -94,7 +94,7 @@ getTodo(id: number) { ### 1.Remove catchError pipe -```tsx +```ts getTodo(id: number) { this.http.get('https://jsonplaceholder.typicode.com/todos/${id}').subscribe(todo => this.todo = todo); } @@ -241,7 +241,7 @@ getTodo() { ![http-request](http-request-7.gif) -Now lets pass **true to `skipHandleError` parameter**, let's see is **errorHandler** going to pass this error. +Now lets pass **true to `skipHandleError` parameter**, let's see is **errorHandler** going to skip this error. ```ts restService = inject(RestService); @@ -259,4 +259,8 @@ getTodo() { ![http-request](http-request-8.gif) +### Conclusion +- To handle synchronous errors globally, you can use [Error Handler](https://angular.io/api/core/ErrorHandler). +- To handle http errors globally, you can use [HTTP - interceptor](https://angular.io/guide/http-interceptor-use-cases). But in this method you won't able to skip spesific cases. I recommend you to use ABP Framework solution + Thanks for reading, if you have any advice please share with me in the comments.