// NewErrorformat compiles given errorformats string (efms) and returns a new
// Errorformat. It returns error if the errorformat is invalid.
776498
func NewErrorformat(efms []string) (*Errorformat, error) {
	errorformat := &Errorformat{Efms: make([]*Efm, 0, len(efms))}
	for _, efm := range efms {
		e, err := NewEfm(efm)
		if err != nil {
			return nil, err
		}
		errorformat.Efms = append(errorformat.Efms, e)
	}
	return errorformat, nil
}
898900
func NewValidationError(err string, warnings ...string) ValidateResponseModel {
	return ValidateResponseModel{
		Error:    err,
		Warnings: warnings,
	}
}
126820
func NewError(code int, msg ...string) *Error {
	e := &errors.CodedError{
		Code: int32(code),
	}
	switch len(msg) {
	case 0:
		e.Message = http.StatusText(code)
	case 1:
		e.Message = msg[0]
	case 2:
		e.Message = msg[0]
		e.Detail = msg[1]
	}
	return (*Error)(e)
}
579576
func ErrorFmt(err error) error {
	if err == nil {
		return nil
	}

	s := err.Error()

	s = strings.Trim(s, "\n .!?")

	count := 0
	s = strings.Map(
		func(r rune) rune {
			defer func() { count++ }()
			if count == 0 {
				return unicode.ToUpper(r)
			}
			return r
		},
		s,
	)

	s = s + "."

	return errors.New(s)
}
368005
func NewErrorPageTemplateRenderer(templateFile string) (ErrorPageRenderer, error) {
	r := &errorPageTemplateRenderer{}
	if len(templateFile) > 0 {
		customTemplate, err := template.ParseFiles(templateFile)
		if err != nil {
			return nil, err
		}
		r.errorPageTemplate = customTemplate
	} else {
		r.errorPageTemplate = defaultErrorPageTemplate
	}

	return r, nil
}
1029236
func NewError(msg string, r io.Reader, offset int) *Error {
	return &Error{
		Message: msg,
		r:       r,
		Offset:  offset,
	}
}
72704
func New(text string, errs ...error) ErrorObject {
	if text != "" {
		errs = append([]error{errors.New(text)}, errs...)
	}
	return NewErrorsSkip(1, errs...)
}
359757
func newError(url string, expected []int, got *httpResponse) error {
	return &UnexpectedResponseError{
		URL:      url,
		Expected: expected,
		Actual:   got.Code,
		Data:     got.Data,
	}
}
868062
func NewValidationError(errorText string, errorFlags uint32) *ValidationError {
	return &ValidationError{
		text:   errorText,
		Errors: errorFlags,
	}
}
373949
func NewError(packageType string, method string, message string, args ...interface{}) Error {
	return Error{
		PackageType: packageType,
		Method:      method,
		Message:     fmt.Sprintf(message, args...),
	}
}
353744
func NewErrorClass(code string, status int) ErrorClass {
	return func(message interface{}, keyvals ...interface{}) error {
		var msg string
		switch actual := message.(type) {
		case string:
			msg = actual
		case error:
			msg = actual.Error()
		case fmt.Stringer:
			msg = actual.String()
		default:
			msg = fmt.Sprintf("%v", actual)
		}
		var meta map[string]interface{}
		l := len(keyvals)
		if l > 0 {
			meta = make(map[string]interface{})
		}
		for i := 0; i < l; i += 2 {
			k := keyvals[i]
			var v interface{} = "MISSING"
			if i+1 < l {
				v = keyvals[i+1]
			}
			meta[fmt.Sprintf("%v", k)] = v
		}
		return &ErrorResponse{ID: newErrorID(), Code: code, Status: status, Detail: msg, Meta: meta}
	}
}
106587
func NewErrorResponder(err error) Responder {
	return func(req *http.Request) (*http.Response, error) {
		return nil, err
	}
}
784666
func newError(pos ast.Pos, err error) error {
	if err == nil {
		return nil
	}
	if pos == nil {
		return &Error{Message: err.Error(), Pos: ast.Position{Line: 1, Column: 1}}
	}
	return &Error{Message: err.Error(), Pos: pos.Position()}
}
920579
func NewError(options ...func(*Error)) *Error {
	err := &Error{}
	for _, o := range options {
		o(err)
	}

	return err
}
203863
func NewErrorParsingURL(u string, e error) ErrorParsingURL {
	return ErrorParsingURL{uri: u, err: e}
}
756279
func Errorf(err error, message string, args ...interface{}) *Error {
	msg := fmt.Sprintf(message, args...)
	return newError(err, msg)
}
545571
func NewError(code ErrorCode, node string) error {
	var message string
	switch code {
	case NodeExists:
		message = fmt.Sprintf("node already exists: %s", node)
	case NoNode:
		message = fmt.Sprintf("node doesn't exist: %s", node)
	case NodeNotEmpty:
		message = fmt.Sprintf("node not empty: %s", node)
	case Timeout:
		message = fmt.Sprintf("deadline exceeded: %s", node)
	case Interrupted:
		message = fmt.Sprintf("interrupted: %s", node)
	case BadVersion:
		message = fmt.Sprintf("bad node version: %s", node)
	case PartialResult:
		message = fmt.Sprintf("partial result: %s", node)
	case NoUpdateNeeded:
		message = fmt.Sprintf("no update needed: %s", node)
	case NoImplementation:
		message = fmt.Sprintf("no such topology implementation %s", node)
	default:
		message = fmt.Sprintf("unknown code: %s", node)
	}
	return Error{
		code:    code,
		message: message,
	}
}