-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherror.go
48 lines (38 loc) · 829 Bytes
/
error.go
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
48
package smsapicom
import "fmt"
const (
// Internal errors
SendErr = 1001
RequestErr = 1002
DecodeJsonErr = 1003
// API errors
RequestApiErr = 8
InvalidMessageApiErr = 11
IncorrectPartsCountApiErr = 12
InvalidNumberApiErr = 13
WrongSenderNameApiErr = 14
InvalidFlashMsgApiErr = 17
InvalidNumberOfParamsApiErr = 18
)
type Error struct {
code int
message string
}
func NewError(code int, msg string) *Error {
return &Error{code: code, message: msg}
}
func (e Error) Error() string {
return fmt.Sprintf("%d: %s", e.code, e.message)
}
func (e Error) GetCode() int {
return e.code
}
func (e *Error) SetCode(code int) {
e.code = code
}
func (e Error) GetMessage() string {
return e.message
}
func (e *Error) SetMessage(msg string) {
e.message = msg
}