csharplang icon indicating copy to clipboard operation
csharplang copied to clipboard

[Proposal]: async method exception filter

Open 333fred opened this issue 11 months ago • 0 comments

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

333fred avatar Jan 06 '25 22:01 333fred