Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to handle the exceptions. #253

Closed
mrjbcs0811 opened this issue Aug 2, 2016 · 5 comments
Closed

How to handle the exceptions. #253

mrjbcs0811 opened this issue Aug 2, 2016 · 5 comments
Labels

Comments

@mrjbcs0811
Copy link

How to handle the exceptions using refit in UWP10?

like Response status code does not indicate success: 401 (Unauthorized) directly goes to catch block.
which can have a callback if we want to do something.

How to get the whole HttpResponseMessage object not only the result.

@flagbug
Copy link
Member

flagbug commented Aug 2, 2016

catch the ApiException that is thrown, there you'll have properties for the status code and friends

@ahmedalejo
Copy link

it´s kind of strange how often this question is asked is there a problem
with the clarity of the documentaion

https://github.com/paulcbetts/refit#user-content-retrieving-the-response

[Get("/users/{user}")]
Task GetUser(string user);

On Tue, 2 Aug 2016 at 09:44 mrjbcs0811 notifications@github.com wrote:

How to handle the exceptions using refit in UWP10?

like Response status code does not indicate success: 401 (Unauthorized)
directly goes to catch block.
which can have a callback if we want to do something.

How to get the whole HttpResponseMessage object not only the result.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#253, or mute the thread
https://github.com/notifications/unsubscribe-auth/AGr-6huK7uj6YfjPCuNvWEatY6CW8wU5ks5qbzukgaJpZM4JakTN
.

@ahmedalejo
Copy link

May be we should make this clearer. But how?

On Tue, 2 Aug 2016 at 09:54 Ahmed Alejo adebunky@gmail.com wrote:

it´s kind of strange how often this question is asked is there a problem
with the clarity of the documentaion

https://github.com/paulcbetts/refit#user-content-retrieving-the-response

[Get("/users/{user}")]
Task GetUser(string user);

On Tue, 2 Aug 2016 at 09:44 mrjbcs0811 notifications@github.com wrote:

How to handle the exceptions using refit in UWP10?

like Response status code does not indicate success: 401 (Unauthorized)
directly goes to catch block.
which can have a callback if we want to do something.

How to get the whole HttpResponseMessage object not only the result.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#253, or mute the thread
https://github.com/notifications/unsubscribe-auth/AGr-6huK7uj6YfjPCuNvWEatY6CW8wU5ks5qbzukgaJpZM4JakTN
.

@KarinBerg
Copy link

A question to HttpResponseMessage: If I use the HttpResponseMessage as return type, then I have to do all the status code handling and the deserialization of the JSON content by myself, right? Refit doesn't offer some handy methods for this?

@bennor
Copy link
Contributor

bennor commented Oct 3, 2016

@KarinBerg Yes - if your interface method returns Task<HttpResponseMessage> then all the decoding of it is up to you.

If you catch ApiException, there's a GetContentAs<T>() method you can use to deserialize a JSON error response.

@bennor bennor closed this as completed Oct 3, 2016
@lock lock bot added the outdated label Jun 25, 2019
@lock lock bot locked and limited conversation to collaborators Jun 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

5 participants