Skip to content

Instantly share code, notes, and snippets.

@crazy2be
Created July 5, 2011 06:18
Show Gist options
  • Save crazy2be/1064335 to your computer and use it in GitHub Desktop.
Save crazy2be/1064335 to your computer and use it in GitHub Desktop.
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