mirror of
https://gitee.com/johng/gf.git
synced 2024-11-29 18:57:44 +08:00
add gcode.WithCode
This commit is contained in:
parent
280c3b4a86
commit
0f67559995
@ -57,3 +57,13 @@ func New(code int, message string, detail interface{}) Code {
|
||||
detail: detail,
|
||||
}
|
||||
}
|
||||
|
||||
// WithCode creates and returns a new error code based on given Code.
|
||||
// The code and message is from given `code`, but the detail if from given `detail`.
|
||||
func WithCode(code Code, detail interface{}) Code {
|
||||
return localCode{
|
||||
code: code.Code(),
|
||||
message: code.Message(),
|
||||
detail: detail,
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user