Created
July 5, 2011 06:18
-
-
Save crazy2be/1064335 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func (e *Exception) debugString() (str string) { | |
defer func() { | |
if r := recover(); r != nil { | |
stringer, ok := r.(Stringer) | |
if !ok { | |
str = "Panic of non-string type when attempting to create string representation." | |
return | |
} | |
str = stringer.String() | |
return | |
} | |
}() | |
if e.val.ctx == nil || e.val == nil { | |
return "Context or value is nil, cannot return a string representation!" | |
} | |
str, err := e.val.ctx.ToString(e.val) | |
if err != nil { | |
return fmt.Sprintf("%#v (failed to convert to string)", e) | |
} | |
return fmt.Sprintf("%#v (string representation: %s)", e, str) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment