aboutsummaryrefslogtreecommitdiff
path: root/user/user.go
diff options
context:
space:
mode:
authorVidhu Kant Sharma <vidhukant@vidhukant.xyz>2022-06-16 21:41:22 +0530
committerVidhu Kant Sharma <vidhukant@vidhukant.xyz>2022-06-16 21:41:22 +0530
commit71210ebc8e04d49a6afeeecee842b2e8b53f3c4f (patch)
tree87bf595e9095604dbf85cdac4cfd133856833f41 /user/user.go
parent052b6604a04ca0909bad714981e3d94c6d9e20b4 (diff)
handling server errors in user, manga and anime package
Diffstat (limited to 'user/user.go')
-rw-r--r--user/user.go12
1 files changed, 5 insertions, 7 deletions
diff --git a/user/user.go b/user/user.go
index 704fed7..0d1cbe5 100644
--- a/user/user.go
+++ b/user/user.go
@@ -30,14 +30,12 @@ func (c Client) GetSelfUserInfo() (UserInfo, error) {
// get data from API
var userData UserInfo
- var errMessage Error
- data := c.requestHandler(endpoint)
- json.Unmarshal([]byte(data), &userData)
- json.Unmarshal([]byte(data), &errMessage)
-
- if errMessage.Err != "" {
- return userData, errors.New(errMessage.Err + " " + errMessage.Msg)
+ data, err := c.requestHandler(endpoint)
+ if err != nil {
+ return userData, err
}
+ json.Unmarshal([]byte(data), &userData)
+
return userData, nil
}