Skip to content

Wrapping of TaskCanceledException #6074

Open
@jhouben98

Description

@jhouben98

Is your feature request related to a problem? Please describe.
When a request is cancelled, an UnexpectedElasticsearchClientException with an inner TaskCanceledException is thrown.
This is very annoying because it's not catched with catch (OperationCanceledException).

Describe the solution you'd like
TaskCanceledException / OperationCanceledException is automatically unwrapped / not wrapped before it's thrown.

Describe alternatives you've considered
I'm currently using this:
catch (UnexpectedElasticsearchClientException ex) when (ex.InnerException is OperationCanceledException)

Additional context
TaskCanceledException is derived from OperationCanceledException.

It's also not recognized by dependent libraries (for example: BackgroundService of .NET Core / Worker Service), meaning they will see an error instead of cancellation when the Elasticsearch Exception is thrown.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions