aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Kiryukhin <a.kiryukhin@mail.ru>2019-09-05 17:23:07 +0300
committerAlexander Kiryukhin <a.kiryukhin@mail.ru>2019-09-05 17:23:07 +0300
commita9d0d8de0bd30fde69a93de4313f3b35060fd94e (patch)
tree0d9699a7832d86ffead58a1d86775a579e33884d
parent8d6c4682dbbb37e64a9f177390d3dfadd99e2ef2 (diff)
Better errors (TamTam errors now implements error interface)v0.2.3
-rw-r--r--client.go3
-rw-r--r--models.go10
2 files changed, 8 insertions, 5 deletions
diff --git a/client.go b/client.go
index 7c5c079..7c918b9 100644
--- a/client.go
+++ b/client.go
@@ -3,7 +3,6 @@ package tamtam
import (
"bytes"
"encoding/json"
- "fmt"
"io"
"net/http"
"net/url"
@@ -48,7 +47,7 @@ func (cl *client) requestReader(method, path string, query url.Values, body io.R
if err != nil {
return nil, err
}
- return nil, fmt.Errorf("code=%s message=%s error=%s", errObj.Code, errObj.Message, errObj.Error)
+ return nil, errObj
}
return resp.Body, err
}
diff --git a/models.go b/models.go
index f449958..5870cb9 100644
--- a/models.go
+++ b/models.go
@@ -228,9 +228,13 @@ type ContactAttachmentRequestPayload struct {
// Server returns this if there was an exception to your request
type Error struct {
- Error string `json:"error,omitempty"` // Error
- Code string `json:"code"` // Error code
- Message string `json:"message"` // Human-readable description
+ ErrorText string `json:"error,omitempty"` // Error
+ Code string `json:"code"` // Error code
+ Message string `json:"message"` // Human-readable description
+}
+
+func (e Error) Error() string {
+ return e.ErrorText
}
type FileAttachment struct {