Skip to content

Commit

Permalink
feat(readme): updated readme
Browse files Browse the repository at this point in the history
  • Loading branch information
zhifenglee-aelf committed Oct 10, 2024
1 parent 7909bf8 commit 539077c
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,16 @@ public class ExceptionHandlingService

```csharp
[ExceptionHandler(typeof(ArgumentNullException), TargetType = typeof(ExceptionHandlingService), MethodName = nameof(ExceptionHandlingService.HandleException))]
public void SomeMethod(int i)
protected virtual Task SomeMethod(int i)
{
// Business logic that may throw exceptions
}
```

All methods with the ExceptionHandler attribute have 2 requirements:
1. The method must return a Task.
2. The method must be virtual or abstract.

### Exception Handling Strategies
There are 3 ways to return the exception through the Flow Behavior:
1. Return: The method will return the ReturnValue implemented.
Expand Down Expand Up @@ -195,7 +199,7 @@ Example with multiple exception handler:
```csharp
[ExceptionHandler(typeof(InvalidOperationException), TargetType = typeof(ExceptionHandlingService), MethodName = nameof(ExceptionHandlingService.HandleException))]
[ExceptionHandler(typeof(ArgumentNullException), TargetType = typeof(ExceptionHandlingService), MethodName = nameof(ExceptionHandlingService.HandleException))]
public void SomeMethod(int i)
public virtual Task SomeMethod(int i)
{
// Business logic that may throw exceptions
}
Expand All @@ -204,7 +208,7 @@ public void SomeMethod(int i)
Or you can have multiple Exceptions:
```csharp
[ExceptionHandler([typeof(ArgumentNullException), typeof(InvalidOperationException)], TargetType = typeof(ExceptionHandlingService), MethodName = nameof(ExceptionHandlingService.HandleException))]
public void SomeMethod(int i)
public virtual Task SomeMethod(int i)
{
// Business logic that may throw exceptions
}
Expand Down

0 comments on commit 539077c

Please sign in to comment.