Skip to content

Commit

Permalink
better error
Browse files Browse the repository at this point in the history
  • Loading branch information
alaingilbert committed Aug 30, 2022
1 parent 41bbec3 commit 55a82a5
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pkg/wrapper/gameforge.go
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,8 @@ type ServerData struct {
// GetServerData gets the server data from xml api
func GetServerData(client httpclient.IHttpClient, ctx context.Context, serverNumber int64, serverLang string) (ServerData, error) {
var serverData ServerData
req, err := http.NewRequest(http.MethodGet, "https://s"+utils.FI64(serverNumber)+"-"+serverLang+".ogame.gameforge.com/api/serverData.xml", nil)
serverDataURL := "https://s" + utils.FI64(serverNumber) + "-" + serverLang + ".ogame.gameforge.com/api/serverData.xml"
req, err := http.NewRequest(http.MethodGet, serverDataURL, nil)
if err != nil {
return serverData, err
}
Expand All @@ -576,7 +577,7 @@ func GetServerData(client httpclient.IHttpClient, ctx context.Context, serverNum
return serverData, err
}
if err := xml.Unmarshal(by, &serverData); err != nil {
return serverData, err
return serverData, fmt.Errorf("failed to xml unmarshal %s : %w", serverDataURL, err)
}
return serverData, nil
}
Expand Down

0 comments on commit 55a82a5

Please sign in to comment.