forked from kubeedge/kubeedge
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
panfeng
authored and
panfeng
committed
Aug 17, 2023
1 parent
4369cba
commit e7c4fe3
Showing
1 changed file
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package model | ||
|
||
import "fmt" | ||
|
||
type Error struct { | ||
Status int `json:"-"` | ||
Code string `json:"code"` | ||
Message string `json:"msg"` | ||
} | ||
|
||
func (e *Error) Error() string { | ||
return fmt.Sprintf("error:status=%v code=%s, message=%s", e.Status, e.Code, e.Message) | ||
} | ||
|
||
func New(status int, code, message string) *Error { | ||
return &Error{ | ||
Status: status, | ||
Code: code, | ||
Message: message, | ||
} | ||
} | ||
|
||
var ( | ||
Success = New(200, "1000", "Success") | ||
ErrInvalidParam = New(400, "1002", "Invalid parameter") | ||
ErrCertEmpty = New(403, "1112", "Domain has no cert") | ||
ErrRequestMethod = New(405, "1113", "Request method error") | ||
ErrInternalServer = New(500, "1001", "Internal server error") | ||
ErrJsonUnmarshal = New(500, "1107", "Json unmarshal error") | ||
ErrFormatResponse = New(500, "1108", "Format http response error") | ||
) |