-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Unhandled exception handler. #109806
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
Unhandled exception handler. #109806
Changes from all commits
5c15489
2cbefea
38b3e7a
c66a034
d80cd9c
92bc4dc
8bd32f2
e9aeb09
eff45d1
5b3f13c
4496367
c7833c5
4fd352e
96ef6e2
d1ade60
fa16227
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 |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using System.Threading; | ||
|
|
||
| namespace System.Runtime.ExceptionServices | ||
| { | ||
| public delegate bool UnhandledExceptionHandler(System.Exception exception); | ||
|
|
||
| public static class ExceptionHandling | ||
| { | ||
| internal static UnhandledExceptionHandler? s_handler; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using System.Threading; | ||
|
|
||
| namespace System.Runtime.ExceptionServices | ||
| { | ||
| public delegate bool UnhandledExceptionHandler(System.Exception exception); | ||
|
Contributor
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. @VSadov the approved API shape used
Member
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.
@VSadov do you have plans to address this? We cannot check in new unapproved public APIs.
Contributor
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. Opened #110254.
Member
Author
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.
Yes. It was an oversight. |
||
|
|
||
| public static class ExceptionHandling | ||
| { | ||
| internal static UnhandledExceptionHandler? s_handler; | ||
|
|
||
| /// <summary> | ||
| /// Sets a handler for unhandled exceptions. | ||
| /// </summary> | ||
| /// <exception cref="ArgumentNullException">If handler is null</exception> | ||
| /// <exception cref="InvalidOperationException">If a handler is already set</exception> | ||
| public static void SetUnhandledExceptionHandler(UnhandledExceptionHandler handler) | ||
| { | ||
| ArgumentNullException.ThrowIfNull(handler); | ||
|
|
||
| if (Interlocked.CompareExchange(ref s_handler, handler, null) != null) | ||
| { | ||
| throw new InvalidOperationException(SR.InvalidOperation_CannotRegisterSecondHandler); | ||
| } | ||
| } | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.