mirror of
https://gitee.com/johng/gf
synced 2026-06-06 02:25:47 +08:00
improve package gcache, add GetVar*/RemoveVar/UpdateVar functions for package gcache
This commit is contained in:
@ -64,7 +64,7 @@ func Newf(format string, args ...interface{}) error {
|
||||
}
|
||||
|
||||
// NewSkip creates and returns an error which is formatted from given text.
|
||||
// The parameter <skip> specifies the stack callers skipped amount.
|
||||
// The parameter `skip` specifies the stack callers skipped amount.
|
||||
func NewSkip(skip int, text string) error {
|
||||
return &Error{
|
||||
stack: callers(skip),
|
||||
@ -74,7 +74,7 @@ func NewSkip(skip int, text string) error {
|
||||
}
|
||||
|
||||
// NewSkipf returns an error that formats as the given format and args.
|
||||
// The parameter <skip> specifies the stack callers skipped amount.
|
||||
// The parameter `skip` specifies the stack callers skipped amount.
|
||||
func NewSkipf(skip int, format string, args ...interface{}) error {
|
||||
return &Error{
|
||||
stack: callers(skip),
|
||||
@ -99,7 +99,7 @@ func Wrap(err error, text string) error {
|
||||
|
||||
// Wrapf returns an error annotating err with a stack trace
|
||||
// at the point Wrapf is called, and the format specifier.
|
||||
// It returns nil if given <err> is nil.
|
||||
// It returns nil if given `err` is nil.
|
||||
func Wrapf(err error, format string, args ...interface{}) error {
|
||||
if err == nil {
|
||||
return nil
|
||||
@ -114,7 +114,7 @@ func Wrapf(err error, format string, args ...interface{}) error {
|
||||
|
||||
// WrapSkip wraps error with text.
|
||||
// It returns nil if given err is nil.
|
||||
// The parameter <skip> specifies the stack callers skipped amount.
|
||||
// The parameter `skip` specifies the stack callers skipped amount.
|
||||
func WrapSkip(skip int, err error, text string) error {
|
||||
if err == nil {
|
||||
return nil
|
||||
@ -129,7 +129,7 @@ func WrapSkip(skip int, err error, text string) error {
|
||||
|
||||
// WrapSkipf wraps error with text that is formatted with given format and args.
|
||||
// It returns nil if given err is nil.
|
||||
// The parameter <skip> specifies the stack callers skipped amount.
|
||||
// The parameter `skip` specifies the stack callers skipped amount.
|
||||
func WrapSkipf(skip int, err error, format string, args ...interface{}) error {
|
||||
if err == nil {
|
||||
return nil
|
||||
@ -165,7 +165,7 @@ func NewCodef(code gcode.Code, format string, args ...interface{}) error {
|
||||
}
|
||||
|
||||
// NewCodeSkip creates and returns an error which has error code and is formatted from given text.
|
||||
// The parameter <skip> specifies the stack callers skipped amount.
|
||||
// The parameter `skip` specifies the stack callers skipped amount.
|
||||
func NewCodeSkip(code gcode.Code, skip int, text ...string) error {
|
||||
errText := ""
|
||||
if len(text) > 0 {
|
||||
@ -179,7 +179,7 @@ func NewCodeSkip(code gcode.Code, skip int, text ...string) error {
|
||||
}
|
||||
|
||||
// NewCodeSkipf returns an error that has error code and formats as the given format and args.
|
||||
// The parameter <skip> specifies the stack callers skipped amount.
|
||||
// The parameter `skip` specifies the stack callers skipped amount.
|
||||
func NewCodeSkipf(code gcode.Code, skip int, format string, args ...interface{}) error {
|
||||
return &Error{
|
||||
stack: callers(skip),
|
||||
@ -207,7 +207,7 @@ func WrapCode(code gcode.Code, err error, text ...string) error {
|
||||
}
|
||||
|
||||
// WrapCodef wraps error with code and format specifier.
|
||||
// It returns nil if given <err> is nil.
|
||||
// It returns nil if given `err` is nil.
|
||||
func WrapCodef(code gcode.Code, err error, format string, args ...interface{}) error {
|
||||
if err == nil {
|
||||
return nil
|
||||
@ -222,7 +222,7 @@ func WrapCodef(code gcode.Code, err error, format string, args ...interface{}) e
|
||||
|
||||
// WrapCodeSkip wraps error with code and text.
|
||||
// It returns nil if given err is nil.
|
||||
// The parameter <skip> specifies the stack callers skipped amount.
|
||||
// The parameter `skip` specifies the stack callers skipped amount.
|
||||
func WrapCodeSkip(code gcode.Code, skip int, err error, text ...string) error {
|
||||
if err == nil {
|
||||
return nil
|
||||
@ -241,7 +241,7 @@ func WrapCodeSkip(code gcode.Code, skip int, err error, text ...string) error {
|
||||
|
||||
// WrapCodeSkipf wraps error with code and text that is formatted with given format and args.
|
||||
// It returns nil if given err is nil.
|
||||
// The parameter <skip> specifies the stack callers skipped amount.
|
||||
// The parameter `skip` specifies the stack callers skipped amount.
|
||||
func WrapCodeSkipf(code gcode.Code, skip int, err error, format string, args ...interface{}) error {
|
||||
if err == nil {
|
||||
return nil
|
||||
@ -265,7 +265,7 @@ func Code(err error) gcode.Code {
|
||||
return gcode.CodeNil
|
||||
}
|
||||
|
||||
// Cause returns the root cause error of <err>.
|
||||
// Cause returns the root cause error of `err`.
|
||||
func Cause(err error) error {
|
||||
if err != nil {
|
||||
if e, ok := err.(apiCause); ok {
|
||||
@ -276,7 +276,7 @@ func Cause(err error) error {
|
||||
}
|
||||
|
||||
// Stack returns the stack callers as string.
|
||||
// It returns the error string directly if the <err> does not support stacks.
|
||||
// It returns the error string directly if the `err` does not support stacks.
|
||||
func Stack(err error) string {
|
||||
if err == nil {
|
||||
return ""
|
||||
|
||||
@ -124,7 +124,7 @@ func (err *Error) Format(s fmt.State, verb rune) {
|
||||
}
|
||||
|
||||
// Stack returns the stack callers as string.
|
||||
// It returns an empty string if the <err> does not support stacks.
|
||||
// It returns an empty string if the `err` does not support stacks.
|
||||
func (err *Error) Stack() string {
|
||||
if err == nil {
|
||||
return ""
|
||||
@ -202,7 +202,7 @@ func formatSubStack(st stack, buffer *bytes.Buffer) {
|
||||
continue
|
||||
}
|
||||
}
|
||||
// Avoid stack string like "<autogenerated>"
|
||||
// Avoid stack string like "`autogenerated`"
|
||||
if strings.Contains(file, "<") {
|
||||
continue
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user