-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherrors.go
42 lines (35 loc) · 899 Bytes
/
errors.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
package wappin
import (
"fmt"
"github.com/fairyhunter13/reflecthelper/v5"
"github.com/pkg/errors"
"net/http"
)
// List of errors used in this package.
var (
ErrNilArguments = errors.New("nil arguments")
)
// Error represents the error for Wappin.
type Error struct {
Status string `json:"status"`
Message string `json:"message"`
}
// Error implements the error interface.
func (e *Error) Error() string {
return fmt.Sprintf("error Wappin status:%s message:%s", e.Status, e.Message)
}
// CastError casts the response to Wappin error.
func CastError(status string, message string) *Error {
return &Error{
Status: status,
Message: message,
}
}
func getError(statusCode int, status string, message string) (err error) {
if !(reflecthelper.GetInt(status) >= http.StatusBadRequest ||
statusCode >= http.StatusBadRequest) {
return
}
err = CastError(status, message)
return
}