-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Code(WEB::ErrorHandling): Implement global error handling
- Loading branch information
1 parent
bdeb60f
commit 1c8f688
Showing
2 changed files
with
43 additions
and
1 deletion.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
src/Client/StellarChat.Client.Web/Layout/CustomErrorBoundary.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using Microsoft.AspNetCore.Components; | ||
using Microsoft.AspNetCore.Components.Web; | ||
using Microsoft.AspNetCore.Components.WebAssembly.Hosting; | ||
|
||
namespace StellarChat.Client.Web.Layout; | ||
|
||
public class CustomErrorBoundary : ErrorBoundary | ||
{ | ||
[Inject] | ||
private IWebAssemblyHostEnvironment? Environment { get; set; } | ||
|
||
protected override Task OnErrorAsync(Exception exception) | ||
{ | ||
if (Environment!.IsDevelopment()) | ||
{ | ||
return base.OnErrorAsync(exception); | ||
} | ||
|
||
return Task.CompletedTask; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters