added ohttps dialer

This commit is contained in:
ginuerzh
2024-04-25 14:59:01 +08:00
parent 766ce7fdaa
commit 41b5e62207
9 changed files with 138 additions and 81 deletions

View File

@ -15,6 +15,16 @@ var (
ErrSave = &Error{statusCode: http.StatusInternalServerError, Code: 40005, Msg: "save config failed"}
)
type ErrCode int
const (
ErrCodeInvalid = 40001
ErrCodeDup = 40002
ErrCodeFailed = 40003
ErrCodeNotFound = 40004
ErrCodeSaveConfigFailed = 40005
)
// Error is an api error.
type Error struct {
statusCode int
@ -22,6 +32,14 @@ type Error struct {
Msg string `json:"msg"`
}
func NewError(status, code int, msg string) error {
return &Error{
statusCode: status,
Code: code,
Msg: msg,
}
}
func (e *Error) Error() string {
b, _ := json.Marshal(e)
return string(b)