From 057bfc250805d3f2085bae076dfb9d4fbad11178 Mon Sep 17 00:00:00 2001 From: Engincan VESKE Date: Thu, 17 Feb 2022 15:07:45 +0300 Subject: [PATCH] Update Error-Handling.md --- docs/en/UI/Blazor/Error-Handling.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/docs/en/UI/Blazor/Error-Handling.md b/docs/en/UI/Blazor/Error-Handling.md index f43456e3a7..35aff041af 100644 --- a/docs/en/UI/Blazor/Error-Handling.md +++ b/docs/en/UI/Blazor/Error-Handling.md @@ -16,6 +16,8 @@ There are different type of `Exception` classes handled differently by the ABP F `UserFriendlyException` is a special type of exception. You can directly show a error message dialog to the user by throwing such an exception. +> For Blazor Server, exceptions must be handled manually. Otherwise it crashes the whole application. Auto Exception Handling is not possible with Blazor Server right now, please follow [this issue](https://github.com/abpframework/abp/issues/8195) to see progress. In meantime, you can use try-catch blocks and call the `HandleErrorAsync` method of ABP to handle errors manually, which shows an error dialog for you. + **Example** ````csharp @@ -26,10 +28,24 @@ There are different type of `Exception` classes handled differently by the ABP F @code { + //for Blazor WASM private void TestException() { throw new UserFriendlyException("A user friendly error message!"); } + + //for Blazor Server + private async Task TestException() + { + try + { + throw new UserFriendlyException("A user friendly error message!"); + } + catch(UserFriendlyException ex) + { + await HandleErrorAsync(ex); + } + } } ````