|
@@ -38,6 +38,12 @@ type UserInfo struct {
|
|
Token string `xml:"authentication-token"`
|
|
Token string `xml:"authentication-token"`
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// ResponseError struct
|
|
|
|
+type ResponseError struct {
|
|
|
|
+ XMLName xml.Name `xml:"errors"`
|
|
|
|
+ Errors []string `xml:"error"`
|
|
|
|
+}
|
|
|
|
+
|
|
// MediaContainer struct
|
|
// MediaContainer struct
|
|
type MediaContainer struct {
|
|
type MediaContainer struct {
|
|
Paths []string `xml:"-"`
|
|
Paths []string `xml:"-"`
|
|
@@ -136,8 +142,17 @@ func (api *API) login() error {
|
|
if err != nil {
|
|
if err != nil {
|
|
return err
|
|
return err
|
|
}
|
|
}
|
|
- log.Debug("LOGIN RESULT\n", string(body))
|
|
|
|
- return xml.Unmarshal(body, &api.userInfo)
|
|
|
|
|
|
+ err = xml.Unmarshal(body, &api.userInfo)
|
|
|
|
+ if err != nil {
|
|
|
|
+ log.Debug("LOGIN RESULT\n", string(body))
|
|
|
|
+ emsg := &ResponseError{}
|
|
|
|
+ if xml.Unmarshal(body, emsg) == nil {
|
|
|
|
+ if len(emsg.Errors) > 0 {
|
|
|
|
+ return fmt.Errorf("%s", emsg.Errors[0])
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return err
|
|
}
|
|
}
|
|
|
|
|
|
// GetServers func
|
|
// GetServers func
|