summaryrefslogtreecommitdiff
path: root/spew/common.go
diff options
context:
space:
mode:
authorThomas NJ Shadwell <[email protected]>2013-02-26 19:43:45 +0000
committerThomas NJ Shadwell <[email protected]>2013-02-26 19:43:45 +0000
commitf948516369ffcd33ed68d8dd95ffe3a120142e79 (patch)
tree6800f99e9bbf9bd145516d82f839d8a4c8dca2d0 /spew/common.go
parent3e74359719b01af0887d1286f6a2bd93824a77ce (diff)
revert previous mis-commits, add ability to allow deeper pretty-printing after an error or Stringer interface is encountered.
Diffstat (limited to 'spew/common.go')
-rw-r--r--spew/common.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/spew/common.go b/spew/common.go
index 6b8bfec..11ec612 100644
--- a/spew/common.go
+++ b/spew/common.go
@@ -150,11 +150,26 @@ func handleMethods(cs *ConfigState, w io.Writer, v reflect.Value) (handled bool)
switch iface := viface.(type) {
case error:
defer catchPanic(w, v)
+ if cs.ContinueOnMethod {
+ w.Write(append(openParenBytes, []byte(iface.Error())...))
+ w.Write(closeParenBytes)
+ w.Write(spaceBytes)
+
+ return false
+ }
+
w.Write([]byte(iface.Error()))
return true
case fmt.Stringer:
defer catchPanic(w, v)
+ if cs.ContinueOnMethod {
+ w.Write(append(openParenBytes, []byte(iface.String())...))
+ w.Write(closeParenBytes)
+ w.Write(spaceBytes)
+
+ return false
+ }
w.Write([]byte(iface.String()))
return true
}