vendor/github.com/pkg/errors/errors.go
changeset 251 1c52a0eeb952
parent 246 0998f404dd31
equal deleted inserted replaced
250:c040f992052f 251:1c52a0eeb952
    80 // the fmt.Formatter interface that can be used for printing information about
    80 // the fmt.Formatter interface that can be used for printing information about
    81 // the stack trace of this error. For example:
    81 // the stack trace of this error. For example:
    82 //
    82 //
    83 //     if err, ok := err.(stackTracer); ok {
    83 //     if err, ok := err.(stackTracer); ok {
    84 //             for _, f := range err.StackTrace() {
    84 //             for _, f := range err.StackTrace() {
    85 //                     fmt.Printf("%+s:%d", f)
    85 //                     fmt.Printf("%+s:%d\n", f, f)
    86 //             }
    86 //             }
    87 //     }
    87 //     }
    88 //
    88 //
    89 // Although the stackTracer interface is not exported by this package, it is
    89 // Although the stackTracer interface is not exported by this package, it is
    90 // considered a part of its stable public interface.
    90 // considered a part of its stable public interface.
   157 	*stack
   157 	*stack
   158 }
   158 }
   159 
   159 
   160 func (w *withStack) Cause() error { return w.error }
   160 func (w *withStack) Cause() error { return w.error }
   161 
   161 
       
   162 // Unwrap provides compatibility for Go 1.13 error chains.
       
   163 func (w *withStack) Unwrap() error { return w.error }
       
   164 
   162 func (w *withStack) Format(s fmt.State, verb rune) {
   165 func (w *withStack) Format(s fmt.State, verb rune) {
   163 	switch verb {
   166 	switch verb {
   164 	case 'v':
   167 	case 'v':
   165 		if s.Flag('+') {
   168 		if s.Flag('+') {
   166 			fmt.Fprintf(s, "%+v", w.Cause())
   169 			fmt.Fprintf(s, "%+v", w.Cause())
   239 }
   242 }
   240 
   243 
   241 func (w *withMessage) Error() string { return w.msg + ": " + w.cause.Error() }
   244 func (w *withMessage) Error() string { return w.msg + ": " + w.cause.Error() }
   242 func (w *withMessage) Cause() error  { return w.cause }
   245 func (w *withMessage) Cause() error  { return w.cause }
   243 
   246 
       
   247 // Unwrap provides compatibility for Go 1.13 error chains.
       
   248 func (w *withMessage) Unwrap() error { return w.cause }
       
   249 
   244 func (w *withMessage) Format(s fmt.State, verb rune) {
   250 func (w *withMessage) Format(s fmt.State, verb rune) {
   245 	switch verb {
   251 	switch verb {
   246 	case 'v':
   252 	case 'v':
   247 		if s.Flag('+') {
   253 		if s.Flag('+') {
   248 			fmt.Fprintf(s, "%+v\n", w.Cause())
   254 			fmt.Fprintf(s, "%+v\n", w.Cause())