forked from carlosdp/twiliogo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherrors.go
More file actions
47 lines (36 loc) · 778 Bytes
/
errors.go
File metadata and controls
47 lines (36 loc) · 778 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package twiliogo
import (
// "fmt"
"encoding/json"
)
type Error struct {
Description string
}
func (e Error) Error() string {
return e.Description
}
type TwilioError struct {
Status int `json:"status"`
Message string `json:"message"`
Code int `json:"code"`
MoreInfo string `json:"more_info"`
Detail string `json:"detail"`
}
func (e TwilioError) Error() string {
/*var message string
message = "Twilio Error, "
if e.Status != 0 {
message += fmt.Sprintf("Status: %d", e.Status)
}
if e.Code != 0 {
message += fmt.Sprintf(", Code: %d", e.Code)
}
if e.Message != "" {
message += ", Message: " + e.Message
}*/
message, err := json.Marshal(e)
if err != nil {
return "{Invalid json response from Twilio}"
}
return string(message)
}