code: func panicToError(err *error) {
  	if r := recover(); r != nil {
  		switch t := r.(type) {
  		case string:
  			*err = errors.New(t)
  		case error:
  			*err = t
  		default: // panic again if we don't know how to handle
  			panic(r)
  		}
  	}
  }
docs: // panicToError converts a panic to an error