File tree Expand file tree Collapse file tree 3 files changed +13
-2
lines changed Expand file tree Collapse file tree 3 files changed +13
-2
lines changed Original file line number Diff line number Diff line change 11Package errors
22============
3- ![ Project status] ( https://img.shields.io/badge/version-1.2 .0-green.svg )
3+ ![ Project status] ( https://img.shields.io/badge/version-1.3 .0-green.svg )
44[ ![ Build Status] ( https://semaphoreci.com/api/v1/joeybloggs/errors/branches/master/badge.svg )] ( https://semaphoreci.com/joeybloggs/errors )
55[ ![ Go Report Card] ( https://goreportcard.com/badge/github.com/go-playground/errors )] ( https://goreportcard.com/report/github.com/go-playground/errors )
66[ ![ GoDoc] ( https://godoc.org/github.com/go-playground/errors?status.svg )] ( https://godoc.org/github.com/go-playground/errors )
Original file line number Diff line number Diff line change 11package errors
22
3+ import "errors"
4+
35var (
46 helpers []Helper
57)
@@ -14,6 +16,10 @@ func RegisterHelper(helper Helper) {
1416// Wrap encapsulates the error, stores a contextual prefix and automatically obtains
1517// a stack trace.
1618func Wrap (err error , prefix string ) (w * Wrapped ) {
19+ return wrap (err , prefix )
20+ }
21+
22+ func wrap (err error , prefix string ) (w * Wrapped ) {
1723 var ok bool
1824 if w , ok = err .(* Wrapped ); ok {
1925 w .Errors = append (w .Errors , newWrapped (err , prefix ))
@@ -73,3 +79,8 @@ func IsErr(err, errType error) bool {
7379 }
7480 return err == errType
7581}
82+
83+ // New creates an error with the provided text and automatically wraps it with line information.
84+ func New (s string ) * Wrapped {
85+ return wrap (errors .New (s ), "" )
86+ }
Original file line number Diff line number Diff line change @@ -114,7 +114,7 @@ func funcname(name string) string {
114114
115115func st () string {
116116 s := callers ()
117- f := fr (s , 2 )
117+ f := fr (s , 3 )
118118 name := fmt .Sprintf ("%n" , f )
119119 file := fmt .Sprintf ("%+s" , f )
120120 line := fmt .Sprintf ("%d" , f )
You can’t perform that action at this time.
0 commit comments