Closed moddyz closed 8 years ago
I've noticed this as well, you can get the error code requiring a person to re-authorize despite giving you a valid set of map objects or player data. You should be able to use it despite the error being thrown.
Not quite sure how to architect this, got any ideas?
Ah I just assumed that because a error was returned that the data part was nil. I can probably handle this on the client side and just ignore the error if data is not nil. Maybe as a start it would be helpful add a comment/docstring to highlight of this potential combination of return values.
I'm still a bit new to Go coming from Python - is error type checking a 'thing'? Could we check that if the data is valid, and the error type is the 'The profile needs to be authorized', then simply log it as a debug/warning message and return nil as error?
@moddyz Something like this:
switch t := err.(type) {
default:
// do something
case *MyErrorType:
// do something else
}
Nice! Good to know. Cheers
So, since we've figured out what this error is, it happens every time the client needs to refresh their API endpoint. I've corrected the name of the error, but I'm going to also add a handler for it to automatically refresh.
Reproduction (basically run the example code provided on README.md):
About half the time I'm getting the error "The profile needs to be authorized" returning from those method calls in 3.
The provider is definitely valid because the other half the time the call returns the player data / map data successfully.
Any ideas? Is there any more info I could provide?