Skip to content

Add hook for exception handling and transforming? #562

@ChristianSauer

Description

@ChristianSauer

Hi,
I am using Refit a lot, and noticed a pattern in my libraries which I dislike:

  1. Use Refit
  2. Notice that exceptions need to be handled somewhat differently than Refits generic mechanism (e.g. instead of throwing a generic ApiException throw an UnauthorizedAccessException if the StatusCode is a 401 or 403).
  3. Write a wrapper interface around refit to statisfy Add top-level API #2

While this is not a large amount of code, it is annoying to write.
Would it be possible to add some attributes to Refit which can be used to instpect a Response and transform it, if necessary?

e.g.

` [Post("/api/v1")]
[OnException(ExceptionHandlingMethod)]

Task CreateAsync([Header("Authorization")] string authorization, [Body] CreateModel);
`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions