errors.go 207 B

12345678910111213
  1. package util
  2. import (
  3. "errors"
  4. "fmt"
  5. )
  6. func NewError(format string, a ...interface{}) error {
  7. if a == nil || len(a) == 0 {
  8. return errors.New(format)
  9. }
  10. return errors.New(fmt.Sprintf(format, a...))
  11. }