feat(IErrorLogger): support Release mode only show exception message#6152
Merged
feat(IErrorLogger): support Release mode only show exception message#6152
Conversation
Contributor
Reviewer's GuideThis PR enhances the error logging component to display only exception messages in non-development environments by injecting the host environment, refactoring the error handling flow (OnErrorAsync and RenderException), introducing an environment check for toast notifications, and standardizing async HandlerException methods across components. Sequence Diagram: RenderException with Handler in Development ModesequenceDiagram
participant Caller
participant BEB as BootstrapBlazorErrorBoundary
participant Logger
participant Env as IHostEnvironment
participant H as "handler (IHandlerException)"
Caller->>BEB: RenderException(exception, handler)
BEB->>BEB: OnErrorAsync(exception)
activate BEB
BEB->>Logger: LogError(exception, "Error details...")
deactivate BEB
BEB->>Env: IsDevelopment()
Env-->>BEB: true
BEB->>H: HandlerException(exception, ExceptionContent)
Sequence Diagram: RenderException with Handler in Non-Development ModesequenceDiagram
participant Caller
participant BEB as BootstrapBlazorErrorBoundary
participant Logger
participant Env as IHostEnvironment
participant TS as ToastService
Caller->>BEB: RenderException(exception, handler)
BEB->>BEB: OnErrorAsync(exception)
activate BEB
BEB->>Logger: LogError(exception, "Error details...")
deactivate BEB
BEB->>Env: IsDevelopment()
Env-->>BEB: false
BEB->>TS: Error(ToastTitle, exception.Message)
Updated Class Diagram for BootstrapBlazorErrorBoundaryclassDiagram
class BootstrapBlazorErrorBoundary {
-IHostEnvironment IHostEnvironment
#OnErrorAsync(Exception exception) Task
+RenderException(Exception exception, IHandlerException? handler) Task
-ShowErrorToast(Exception exception) Task
}
BootstrapBlazorErrorBoundary --|> ErrorBoundaryBase
BootstrapBlazorErrorBoundary ..> IHostEnvironment : uses
BootstrapBlazorErrorBoundary ..> IHandlerException : uses
BootstrapBlazorErrorBoundary ..> ToastService : uses
BootstrapBlazorErrorBoundary ..> ILogger : uses
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Contributor
There was a problem hiding this comment.
Hey @ArgoZhang - I've reviewed your changes - here's some feedback:
- Rename the injected IHostEnvironment property to HostEnvironment (or a similar non-interface-prefixed name) to avoid confusion.
- Refactor the repeated ToastService.Error and environment-check logic into a shared helper to reduce duplication.
- For methods that only await and return a single Task (e.g. HandlerException), consider removing the async keyword and returning the Task directly.
Here's what I looked at during the review
- 🟡 General issues: 2 issues found
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #6152 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 703 703
Lines 31108 31119 +11
Branches 4398 4399 +1
=========================================
+ Hits 31108 31119 +11 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Link issues
fixes #6151
Summary By Copilot
Regression?
Risk
Verification
Packaging changes reviewed?
☑️ Self Check before Merge
Summary by Sourcery
Support showing only exception messages in release mode by injecting IHostEnvironment into the error boundary, refactoring the error-handling flow, and updating handler implementations to async for full details in development and minimal messaging in production
New Features:
Enhancements: