u
This commit is contained in:
1 parent
2d036f4d95
commit
f373cf956d
22 files changed
+568
-280
No files matched your search
@@ -1,7 +1,7 @@
|
||||
package router
|
||||
|
||||
import (
|
||||
"base-framework/pkg/utils"
|
||||
error2 "base-framework/pkg/utils/error"
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"io"
|
||||
@@ -115,6 +115,7 @@ func (c *Context) Set(key string, value interface{}) {
|
||||
c.keys = make(map[string]interface{})
|
||||
}
|
||||
c.keys[key] = value
|
||||
|
||||
}
|
||||
|
||||
// Get 取值
|
||||
@@ -137,21 +138,21 @@ func (c *Context) AddError(err error) {
|
||||
}
|
||||
|
||||
if _, exists := c.keys["errors"]; !exists {
|
||||
c.keys["errors"] = []*utils.StackError{}
|
||||
c.keys["errors"] = []*error2.StackError{}
|
||||
}
|
||||
|
||||
// 统一生成堆栈
|
||||
se := utils.WrapWithStack(err)
|
||||
c.keys["errors"] = append(c.keys["errors"].([]*utils.StackError), se)
|
||||
se := error2.WrapWithStack(err)
|
||||
c.keys["errors"] = append(c.keys["errors"].([]*error2.StackError), se)
|
||||
}
|
||||
|
||||
// Errors 返回 []*utils.StackError
|
||||
func (c *Context) Errors() []*utils.StackError {
|
||||
func (c *Context) Errors() []*error2.StackError {
|
||||
if c.keys == nil {
|
||||
return nil
|
||||
}
|
||||
if errs, exists := c.keys["errors"]; exists {
|
||||
return errs.([]*utils.StackError)
|
||||
return errs.([]*error2.StackError)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Reference in new issue
Block a user