Error implements error.Error.
()
| 156 | |
| 157 | // Error implements error.Error. |
| 158 | func (e *Err) Error() string { |
| 159 | // We want to walk up the stack of errors showing the annotations |
| 160 | // as long as the cause is the same. |
| 161 | err := e.previous |
| 162 | if !sameError(Cause(err), e.cause) && e.cause != nil { |
| 163 | err = e.cause |
| 164 | } |
| 165 | switch { |
| 166 | case err == nil: |
| 167 | return e.message |
| 168 | case e.message == "": |
| 169 | return err.Error() |
| 170 | } |
| 171 | return fmt.Sprintf("%s: %v", e.message, err) |
| 172 | } |
| 173 | |
| 174 | // Format implements fmt.Formatter |
| 175 | // When printing errors with %+v it also prints the stack trace. |