refit icon indicating copy to clipboard operation
refit copied to clipboard

Refit using Results pattern

Open RHaughton opened this issue 2 years ago • 0 comments

I'm trying to create Refit API Client with some user feedback.

I use FluentResults in my Web Api and I have created some custom Errors for some common scenarios. (NotFoundError, AlreadyExists, Validation, etc...). based on the TypeOfError I automatically send an appropriate status code.

Each of those errors also contain some text information like "User not found. Id: '{UserId}' ". I would like the RefitClient retrieve this information in the APIException object or the ReasonPhrase property. I then show this information on my frontend for user feedback. Without using Refit I have an APIResult object which encapsulate the Error but I would like to add it to the APIResponse (since it's already there).

Is there a way to customize the APIResponse object with some user feedback? Or should I stick to my old way of doing it and always return some kind of the Result Object with user feedback in it?

RHaughton avatar Apr 24 '23 11:04 RHaughton