-
-
Notifications
You must be signed in to change notification settings - Fork 173
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
Exception with status code #17
Comments
Hi @caneva20, thanks for report this issue! Check the validations that I have https://github.com/proyecto26/RestClient/blob/master/src/Proyecto26.RestClient/HttpActions/HttpBase.cs#L17 What do you think? What changes do you propose to improve the RequestException class? Other option is change the access of the Unity Request to be public to get the info https://github.com/proyecto26/RestClient/blob/master/src/Proyecto26.RestClient/Utils/RequestHelper.cs#L67
I prefer to add more information to the RequestException, but let me know what you think |
Hi @jdnichollsc , I've just forked the project and I'm changing things here and there to make it work for me. I haven't thought about adding more things to RequestException, but I agree that this is a great solution, and probably the best the way, what I've done now was just a quick fix, (I'm appending the code and desc the to error description, hehe). One other change that I've made to this class was here https://github.com/proyecto26/RestClient/blob/master/src/Proyecto26.RestClient/HttpActions/HttpBase.cs#L17 Instead of That way no changes need to be made to RequestException and only if there's a NetworkError an error will be returned. BUT this may not desired by everyone, I don't know. What you think? |
Ok, what you think if we add a new property called IgnoreHttpException from RequestHelper class to ignore http exceptions? |
Humm, I think that's is pretty great actually, and it will be fine for everyone. |
@caneva20 sounds great, let me publish a new version of the plugin this weekend |
@jdnichollsc I should thank you for the attention. Thanks! |
Any comment from the unity store is really appreciated! 👍 https://assetstore.unity.com/packages/tools/network/rest-client-for-unity-102501 |
Hi @jdnichollsc I've tested it with my server and it works fine, now I can have more control over each request and do what I need. One thing that you may have not realized is that the demo does not work anymore, 'cause you renamed some variables, quickly you'll fix it, I'm saying just to let you know. Thanks man! :) |
Hi @caneva20 :) |
@caneva20 thanks for your comments from the Unity store! 👍 Pull request => #18 Regards, Nicholls |
Check my friend the files modified, thanks for your help and patience! 💯 https://github.com/proyecto26/RestClient/pull/18/files |
@caneva20 any good comment from the Unity Asset Store would be really appreciated :) |
Hello @jdnichollsc, I've updated my comment there, I just don't know how to update the "on previous version 1.2.2" and since I'm already here I would like to suggest one more thing, but that time is pretty simple, as you might have noticed, I don't like JSONUtility and the I can recommend two libs that work nicely with Unity:
But that is really up to you. :) |
ohh any pull request is welcome my friend! |
Hi, I've been using the package for a week now, it's pretty good actually but there's one thing that bothers me, Exception does not have a status code and/or the description from the server.
I've been looking into your code and found that you return the error from UnityWebRequest which does not have neither the status code or a description from the server, in case my server return a 400 (BadRequest) with a description why it has failed. Both of those thing can be gathered pretty ease since you are creating a RequestException and have a RequestHelper in your disposal, which has both of those things.
To make it a little more clear why it's a good "feature" I'll leave a snippet below.
If something goes wrong here (
return RestClient.Post($"{URL}/token", model);
) the second Then() won't be called, and that's fine, but catching the exception does not help me 'cause it does not say what really happened there*EDIT
After posting this I realized that even this change won't be enough for some cases. Using my own scenario, when opening the app, the user should log in, he/she might type the wrong email/password, if that is the case, the server will return a 401 (Unauthorized) (or you may want a 400 (BadRequest)), none of those are really an error, at least not a error to be "catchched" (in the Catch()), i would like to have them in the Then(), my
case 401:
(in the switch) will never be called, since server returned errors are treated as generic errors.The EDIT part are just some thoughts, I'm not trying to suggest anything, is just, I don't know, my case is "special", (is it?)
The text was updated successfully, but these errors were encountered: