mirror of
https://gitee.com/johng/gf.git
synced 2024-12-01 19:57:40 +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,
|
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