mirror of
https://github.com/ramsayleung/rspotify.git
synced 2026-04-26 16:05:53 +03:00
[GH-ISSUE #63] Get Player Error Reasons #21
Labels
No labels
Stale
bug
discussion
enhancement
good first issue
good first issue
help wanted
pull-request
question
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/rspotify#21
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @sputnick1124 on GitHub (Nov 9, 2019).
Original GitHub issue: https://github.com/ramsayleung/rspotify/issues/63
Over in
spotify-tui, I am getting API errors fairly frequently. Much of the time, the error code is 403 (I am able to see that now since https://github.com/ramsayleung/rspotify/pull/62), which likely means that I am getting a player error, but I get no more information than that.I'm not great at web stuff; I don't understand what is happening to this object in the request response. I figured I would be able to define a struct to hold the player error:
and then (deserialize the json)[https://docs.rs/reqwest/0.10.0-alpha.1/reqwest/struct.Response.html#method.json] from the response directly into it, but
reqwestseems to be hiding the json from me somehow. What's happening to it? How can I get access to the error reason? This would help immensely in providing more information about failure to both developers and end-users.I'm happy to implement any changes that need to happen, but I don't have much experience handling web requests, and none of that experience is with Rust/
reqwest, so any other devs here that could shed some light would be appreciated.@sputnick1124 commented on GitHub (Nov 9, 2019):
For reference, this is what I see when interacting with the endpoint through the (API
The
Responseobject fromreqwest, however, does not seem to provide any access to that json object. It would seem I am potentially missing something obvious, but I don't know what.@ramsayleung commented on GitHub (Nov 12, 2019):
Do you mean that the
reqwestwill hide theerrormessage from the response, could you help me reproduce this case by doing it step by step?@TimotheeGerber commented on GitHub (Apr 19, 2020):
I am only guessing here, but I think that @sputnick1124 tried to print the
reqwest'sResponsewith something like:Unfortunately, the implementation of the
Debugtrait forResponsedoes not show the body of the response, only the URL, status and headers (see the implementation here). It leads @sputnick1124 to believe that the JSON returned by Spotify is not in theResponse. But it is. You can get the body with the.text(),.bytes()or even.json()methods.@sputnick1124 commented on GitHub (Apr 20, 2020):
@TimotheeGerber is correct. I was naively just printing out the
Responseobject and neglected to go look at it's implementation. I have a clear idea now of what I am trying to do. I'll work on a PR and get that up sometime this week.Thanks, @TimotheeGerber!
@sputnick1124 commented on GitHub (Apr 23, 2020):
PR is open. Please provide any comments/suggestions for improvement.