Closed bouk closed 3 years ago
Thanks for the suggestion. That helper would be handy.
However, the errors package tries to be minimal by design. This ensures simplicity and performance.
Projects are encouraged to build their own error utils with their own constructors and wrappers. For example:
package errorutil
func TwirpErrorf(code twirp.ErrorCode, format string, a ...interface{}) {
return twirp.NewError(code, fmt.Sprintf(format, a...))
}
Hi there, it would be handy to have an Errorf function to make it easy to parameterize errors, alternatively we could have NewError and InternalError take
args ...interface{}
and then pass that to Sprintf in the function.If you're open to this I can make a PR.