MCPcopy Create free account
hub / github.com/juju/errors / Format

Method Format

error.go:177–198  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

175// When printing errors with %+v it also prints the stack trace.
176// %#v unsurprisingly will print the real underlying type.
177func (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
201type unformatter Err

Callers

nothing calls this directly

Calls 2

ErrorMethod · 0.95
ErrorStackFunction · 0.85

Tested by

no test coverage detected