-
Notifications
You must be signed in to change notification settings - Fork 4.2k
More fault handling cleanup #59097
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
base: main
Are you sure you want to change the base?
More fault handling cleanup #59097
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -93,7 +93,7 @@ public static void CopyHandlerTo(Assembly assembly) | |
/// </summary> | ||
/// <returns><see langword="false"/> to avoid catching the exception.</returns> | ||
[DebuggerHidden] | ||
public static bool ReportAndPropagate(Exception exception, ErrorSeverity severity = ErrorSeverity.Uncategorized) | ||
public static bool ReportAndPropagate(Exception exception, ErrorSeverity severity) | ||
{ | ||
Report(exception, severity); | ||
return false; | ||
|
@@ -105,7 +105,7 @@ public static bool ReportAndPropagate(Exception exception, ErrorSeverity severit | |
/// </summary> | ||
/// <returns><see langword="false"/> to avoid catching the exception.</returns> | ||
[DebuggerHidden] | ||
public static bool ReportAndPropagateUnlessCanceled(Exception exception, ErrorSeverity severity = ErrorSeverity.Uncategorized) | ||
public static bool ReportAndPropagateUnlessCanceled(Exception exception, ErrorSeverity severity) | ||
{ | ||
if (exception is OperationCanceledException) | ||
{ | ||
|
@@ -134,7 +134,7 @@ public static bool ReportAndPropagateUnlessCanceled(Exception exception, ErrorSe | |
/// <see cref="CancellationToken.IsCancellationRequested"/> set if cancellation is expected.</param> | ||
/// <returns><see langword="false"/> to avoid catching the exception.</returns> | ||
[DebuggerHidden] | ||
public static bool ReportAndPropagateUnlessCanceled(Exception exception, CancellationToken contextCancellationToken, ErrorSeverity severity = ErrorSeverity.Uncategorized) | ||
public static bool ReportAndPropagateUnlessCanceled(Exception exception, ErrorSeverity severity, CancellationToken contextCancellationToken) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did 'Change Signature' make this easy? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It did! Although sometimes it did nothing at all, and my effort to debug that kept resulting in the debugger breaking. 😄 |
||
{ | ||
if (ExceptionUtilities.IsCurrentOperationBeingCancelled(exception, contextCancellationToken)) | ||
{ | ||
|
@@ -160,14 +160,14 @@ public static bool ReportAndPropagateUnlessCanceled(Exception exception, Cancell | |
/// </summary> | ||
/// <returns>True to catch the exception.</returns> | ||
[DebuggerHidden] | ||
public static bool ReportAndCatch(Exception exception, ErrorSeverity severity = ErrorSeverity.Uncategorized) | ||
public static bool ReportAndCatch(Exception exception, ErrorSeverity severity) | ||
{ | ||
Report(exception, severity); | ||
return true; | ||
} | ||
|
||
[DebuggerHidden] | ||
public static bool ReportWithDumpAndCatch(Exception exception, ErrorSeverity severity = ErrorSeverity.Uncategorized) | ||
public static bool ReportWithDumpAndCatch(Exception exception, ErrorSeverity severity) | ||
{ | ||
Report(exception, severity, forceDump: true); | ||
return true; | ||
|
@@ -180,7 +180,7 @@ public static bool ReportWithDumpAndCatch(Exception exception, ErrorSeverity sev | |
/// <returns><see langword="true"/> to catch the exception if the error was reported; otherwise, | ||
/// <see langword="false"/> to propagate the exception if the operation was cancelled.</returns> | ||
[DebuggerHidden] | ||
public static bool ReportAndCatchUnlessCanceled(Exception exception, ErrorSeverity severity = ErrorSeverity.Uncategorized) | ||
public static bool ReportAndCatchUnlessCanceled(Exception exception, ErrorSeverity severity) | ||
{ | ||
if (exception is OperationCanceledException) | ||
{ | ||
|
@@ -210,7 +210,7 @@ public static bool ReportAndCatchUnlessCanceled(Exception exception, ErrorSeveri | |
/// <returns><see langword="true"/> to catch the exception if the error was reported; otherwise, | ||
/// <see langword="false"/> to propagate the exception if the operation was cancelled.</returns> | ||
[DebuggerHidden] | ||
public static bool ReportAndCatchUnlessCanceled(Exception exception, CancellationToken contextCancellationToken, ErrorSeverity severity = ErrorSeverity.Uncategorized) | ||
public static bool ReportAndCatchUnlessCanceled(Exception exception, ErrorSeverity severity, CancellationToken contextCancellationToken) | ||
{ | ||
if (ExceptionUtilities.IsCurrentOperationBeingCancelled(exception, contextCancellationToken)) | ||
{ | ||
|
@@ -224,7 +224,7 @@ public static bool ReportAndCatchUnlessCanceled(Exception exception, Cancellatio | |
|
||
private static readonly object s_reportedMarker = new(); | ||
|
||
private static void Report(Exception exception, ErrorSeverity severity = ErrorSeverity.Uncategorized, bool forceDump = false) | ||
private static void Report(Exception exception, ErrorSeverity severity, bool forceDump = false) | ||
{ | ||
// hold onto last exception to make investigation easier | ||
s_reportedException = exception; | ||
|
@@ -264,11 +264,6 @@ private static void Report(Exception exception, ErrorSeverity severity = ErrorSe | |
/// </summary> | ||
internal enum ErrorSeverity | ||
{ | ||
/// <summary> | ||
/// The severity hasn't been categorized. Don't use this in new code. | ||
/// </summary> | ||
Uncategorized, | ||
|
||
/// <summary> | ||
/// Something failed, but the user is unlikely to notice. Especially useful for background things that we can silently recover | ||
/// from, like bugs in caching systems. | ||
|
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.
ErrorSeverity.General should be the default. This coding pattern is unnecessarily burdensome.