Skip to content

Commit

Permalink
feat(README): updated readme with new feature
Browse files Browse the repository at this point in the history
  • Loading branch information
zhifenglee-aelf committed Oct 10, 2024
1 parent 50705e9 commit affe522
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,30 @@ public async Task Finally(CreateBookInput message)
}
```

### Logging
The `LogOnly` attribute is used to log exceptions without handling them. This will result in a rethrow. All logs are logged by `ILogger`. If `LogOnly` is set to `false`, the exception will still be logged and will continue to handle the exception through the assigned method. By default, `LogOnly = false`.
```csharp
[ExceptionHandler(typeof(Exception), LogOnly = true)]
protected virtual async Task<bool> SomeMethod(string message)
{
throw new Exception("boo!");
return false;
}
```

You may also set the LogLevel for the output of the exception. For example:
```csharp
[ExceptionHandler(typeof(Exception),
LogLevel = LogLevel.Information,
TargetType = typeof(BookAppService),
MethodName = nameof(HandleException))]
protected virtual async Task<bool> SomeMethod(string message)
{
throw new Exception("boo!");
return false;
}
```

## Examples

Example with multiple exception handler:
Expand Down

0 comments on commit affe522

Please sign in to comment.