Skip to content

Commit 4d523d1

Browse files
committed
补充链式调用
1 parent 53e8a2e commit 4d523d1

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

exception/base.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ import "fmt"
66
type APIException interface {
77
error
88
ErrorCode() int
9-
WithMeta(m interface{})
9+
WithMeta(m interface{}) APIException
1010
Meta() interface{}
11-
WithData(d interface{})
11+
WithData(d interface{}) APIException
1212
Data() interface{}
1313
Is(code int) bool
1414
Namespace() string
@@ -44,16 +44,18 @@ func (e *exception) ErrorCode() int {
4444
}
4545

4646
// WithMeta 携带一些额外信息
47-
func (e *exception) WithMeta(m interface{}) {
47+
func (e *exception) WithMeta(m interface{}) APIException {
4848
e.meta = m
49+
return e
4950
}
5051

5152
func (e *exception) Meta() interface{} {
5253
return e.meta
5354
}
5455

55-
func (e *exception) WithData(d interface{}) {
56+
func (e *exception) WithData(d interface{}) APIException {
5657
e.data = d
58+
return e
5759
}
5860

5961
func (e *exception) Data() interface{} {

0 commit comments

Comments
 (0)