Format implements fmt.Formatter When printing errors with %+v it also prints the stack trace. %#v unsurprisingly will print the real underlying type.
(s fmt.State, verb rune)
| 175 | // When printing errors with %+v it also prints the stack trace. |
| 176 | // %#v unsurprisingly will print the real underlying type. |
| 177 | func (e *Err) Format(s fmt.State, verb rune) { |
| 178 | switch verb { |
| 179 | case 'v': |
| 180 | switch { |
| 181 | case s.Flag('+'): |
| 182 | fmt.Fprintf(s, "%s", ErrorStack(e)) |
| 183 | return |
| 184 | case s.Flag('#'): |
| 185 | // avoid infinite recursion by wrapping e into a type |
| 186 | // that doesn't implement Formatter. |
| 187 | fmt.Fprintf(s, "%#v", (*unformatter)(e)) |
| 188 | return |
| 189 | } |
| 190 | fallthrough |
| 191 | case 's': |
| 192 | fmt.Fprintf(s, "%s", e.Error()) |
| 193 | case 'q': |
| 194 | fmt.Fprintf(s, "%q", e.Error()) |
| 195 | default: |
| 196 | fmt.Fprintf(s, "%%!%c(%T=%s)", verb, e, e.Error()) |
| 197 | } |
| 198 | } |
| 199 | |
| 200 | // helper for Format |
| 201 | type unformatter Err |
nothing calls this directly
no test coverage detected