-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #42 from thomaslevesque/handler-exception-handling
Handle exceptions thrown by handlers
- Loading branch information
Showing
10 changed files
with
677 additions
and
49 deletions.
There are no files selected for viewing
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
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
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,20 @@ | ||
using System; | ||
|
||
namespace WeakEvent | ||
{ | ||
/// <summary> | ||
/// Flags that specify what to do with exceptions thrown by individual event handlers. | ||
/// An exception handler passed to <c>Raise</c> or <c>RaiseAsync</c> can return any combination | ||
/// of thse flags. | ||
/// </summary> | ||
[Flags] | ||
public enum ExceptionHandlingFlags | ||
{ | ||
/// <summary>Do nothing.</summary> | ||
None = 0, | ||
/// <summary>Mark the exception as handled. If this flag isn't set, the exception will be rethrown.</summary> | ||
Handled = 1, | ||
/// <summary>Unsubscribe the handler that caused the exception.</summary> | ||
Unsubscribe = 2 | ||
} | ||
} |
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,12 @@ | ||
using System; | ||
|
||
namespace WeakEvent | ||
{ | ||
internal interface IStrongHandler<TOpenEventHandler, TStrongHandler> | ||
where TOpenEventHandler : Delegate | ||
where TStrongHandler : struct, IStrongHandler<TOpenEventHandler, TStrongHandler> | ||
{ | ||
object? Target { get; } | ||
WeakDelegate<TOpenEventHandler, TStrongHandler> WeakHandler { get; } | ||
} | ||
} |
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,8 @@ | ||
using System; | ||
|
||
namespace WeakEvent | ||
{ | ||
internal delegate TStrongHandler StrongHandlerFactory<TOpenEventHandler, TStrongHandler>(object? target, WeakDelegate<TOpenEventHandler, TStrongHandler> weakHandler) | ||
where TOpenEventHandler : Delegate | ||
where TStrongHandler : struct, IStrongHandler<TOpenEventHandler, TStrongHandler>; | ||
} |
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
Oops, something went wrong.