csharplang
csharplang copied to clipboard
[Proposal]: async method exception filter
async method exception filter
- Specification: None yet
- Discussion: https://github.com/dotnet/csharplang/discussions/9000
Summary
Allow customizing the exception handling produced for async methods.
Adding the following attribute:
[module: AsyncExceptionFilter(typeof(MyExceptionHandler)]
would result in the generated try/catch having a modified catch clause:
catch (Exception e) when (MyExceptionHandler.Report(e); true)
{
... existing handling logic ...
}
where we could find the following method void Report(Exception).
Design meetings
- https://github.com/dotnet/csharplang/blob/main/meetings/2022/LDM-2022-09-28.md#ungrouped