code: func (p *GoTemplatePrinter) safeExecute(w io.Writer, obj interface{}) error {
  	var panicErr error
  	// Sorry for the double anonymous function. There's probably a clever way
  	// to do this that has the defer'd func setting the value to be returned, but
  	// that would be even less obvious.
  	retErr := func() error {
  		defer func() {
  			if x := recover(); x != nil {
  				panicErr = fmt.Errorf("caught panic: %+v", x)
  			}
  		}()
  		return p.template.Execute(w, obj)
  	}()
  	if panicErr != nil {
  		return panicErr
  	}
  	return retErr
  }
docs: // safeExecute tries to execute the template, but catches panics and returns an error
  // should the template engine panic.