diff options
Diffstat (limited to 'lib/errors/errors.go')
| -rw-r--r-- | lib/errors/errors.go | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/errors/errors.go b/lib/errors/errors.go index 35b74d1c..b9a5b9bd 100644 --- a/lib/errors/errors.go +++ b/lib/errors/errors.go @@ -7,6 +7,7 @@ package errors import ( "net/http" + "reflect" ) // @@ -58,6 +59,19 @@ func (e *E) Error() string { } // +// As set the target to e only if only target is **E. +// +func (e *E) As(target interface{}) bool { + _, ok := target.(**E) + if ok { + val := reflect.ValueOf(target) + val.Elem().Set(reflect.ValueOf(e)) + return ok + } + return false +} + +// // Unwrap return the internal error. // func (e *E) Unwrap() error { |
