@@ -95,11 +95,18 @@ type SteamProfile struct {
95
95
SteamID uint64 `json:"steamid"`
96
96
}
97
97
98
+ // SteamError contains a possible error response from the Steam Web API.
99
+ type SteamError struct {
100
+ ErrorCode int `json:"errorcode"`
101
+ ErrorDesc string `json:"errordesc"`
102
+ }
103
+
98
104
// Unwrapping the SteamProfile
99
105
type SteamProfileWrapper struct {
100
- Response struct {
101
- Params SteamProfile `json:"params"`
102
- } `json:"response"`
106
+ Response struct {
107
+ Params * SteamProfile `json:"params"`
108
+ Error * SteamError `json:"error"`
109
+ } `json:"response"`
103
110
}
104
111
105
112
// NewClient creates a new Social Client
@@ -445,7 +452,13 @@ func (c *Client) GetSteamProfile(ctx context.Context, publisherKey string, appID
445
452
if err != nil {
446
453
return nil , err
447
454
}
448
- return & profileWrapper .Response .Params , nil
455
+ if profileWrapper .Response .Error != nil {
456
+ return nil , fmt .Errorf ("%v, %v" , profileWrapper .Response .Error .ErrorDesc , profileWrapper .Response .Error .ErrorCode )
457
+ }
458
+ if profileWrapper .Response .Params == nil {
459
+ return nil , errors .New ("no steam profile" )
460
+ }
461
+ return profileWrapper .Response .Params , nil
449
462
}
450
463
451
464
func (c * Client ) request (ctx context.Context , provider , path string , headers map [string ]string , to interface {}) error {
0 commit comments