-
-
Notifications
You must be signed in to change notification settings - Fork 363
feat(IErrorLogger): support Release mode only show exception message #6152
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
src/BootstrapBlazor/Components/ErrorLogger/BootstrapBlazorErrorBoundary.cs
Outdated
Show resolved
Hide resolved
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:
|
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: