// ToError converts Errors to the error interface
// returns nil if no errors are present, a single error object if only one is present
167762
func (errs Errors) ToError() error {
	if len(errs) == 0 {
		return nil
	}
	if len(errs) == 1 {
		return errs[0]
	}
	return errs
}
1083208
func FailOnError(err error, msg string) {
	if err != nil {
		msg := fmt.Sprintf("%s: %s", msg, err)
		Fail(msg)
	}
}
983137
func (c *Container) Err() error {
	if c.err == io.EOF {
		return nil
	}
	return c.err
}
160838
func (e *DDLExec) toErr(err error) error {
	if e.ctx.GetSessionVars().StmtCtx.IsDDLJobInQueue {
		return err
	}

	// Before the DDL job is ready, it encouters an error that may be due to the outdated schema information.
	// After the DDL job is ready, the ErrInfoSchemaChanged error won't happen because we are getting the schema directly from storage.
	// So we needn't to consider this condition.
	// Here we distinguish the ErrInfoSchemaChanged error from other errors.
	dom := domain.GetDomain(e.ctx)
	checker := domain.NewSchemaChecker(dom, e.is.SchemaMetaVersion(), nil)
	txn, err1 := e.ctx.Txn(true)
	if err1 != nil {
		logutil.Logger(context.Background()).Error("active txn failed", zap.Error(err))
		return err1
	}
	schemaInfoErr := checker.Check(txn.StartTS())
	if schemaInfoErr != nil {
		return errors.Trace(schemaInfoErr)
	}
	return err
}
86246
func (s *Status) Err() error {
	if s.Code() == codes.OK {
		return nil
	}
	return (*statusError)(s.s)
}
853961
func (g *globTokeniser) Err() error {
	if g.err == io.EOF {
		return nil
	}

	return g.err
}
264438
func (c *requestContext) err(e error, msg string, args ...interface{}) {
	code := 0
	switch {
	case e == nil:
		panic("nil")
	case tq.Retry.In(e):
		code = 409
	case transient.Tag.In(e):
		code = 500
	default:
		code = 202 // fatal error, don't need a redelivery
	}
	args = append(args, e)
	c.fail(code, msg+" - %s", args...)
}
265703
func (err *Error) Error() string {
	return fmt.Sprintf("%s: %s", err.Err, err.Msg)
}
289802
func (c *Completion) Err() error {
	c.lock.Lock()
	defer c.lock.Unlock()
	return c.err
}
204444
func errstr(errno int) string {
	// ask windows for the remaining errors
	var flags uint32 = syscall.FORMAT_MESSAGE_FROM_SYSTEM | syscall.FORMAT_MESSAGE_ARGUMENT_ARRAY | syscall.FORMAT_MESSAGE_IGNORE_INSERTS
	b := make([]uint16, 300)
	n, err := syscall.FormatMessage(flags, 0, uint32(errno), 0, b, nil)
	if err != nil {
		return fmt.Sprintf("error %d (FormatMessage failed with: %v)", errno, err)
	}
	// trim terminating \r and \n
	for ; n > 0 && (b[n-1] == '\n' || b[n-1] == '\r'); n-- {
	}
	return string(utf16.Decode(b[:n]))
}
1314213
func (e *Error) ToError() error {
	if e == nil {
		return nil
	}

	code := codes.Code(e.GrpcCode)
	err := status.Errorf(code, "%s", e.Msg)
	if e.Transient || grpcutil.IsTransientCode(code) {
		err = transient.Tag.Apply(err)
	}
	return err
}
1211463
func (e Errors) Error() string {
	ret := ""
	if len(e) > 0 {
		ret = fmt.Sprintf("Errors:\n")
		ret += strings.Join(e, "\n")
	}
	return ret
}
286366
func (iter *Iterator) Err() error {
	var cErr *C.char
	C.rocksdb_iter_get_error(iter.c, &cErr)
	if cErr != nil {
		defer C.free(unsafe.Pointer(cErr))
		return errors.New(C.GoString(cErr))
	}
	return nil
}
1243803
func (fer *FirstErrorRecorder) Error() error {
	fer.mu.Lock()
	defer fer.mu.Unlock()
	return fer.firstError
}
20164
func (r *responseIterator) Err() error {
	if r.response.Err != "" {
		return fmt.Errorf(r.response.Err)
	}

	return nil
}
310052
func (c Context) Err(err error) Context {
	return c.AnErr(ErrorFieldName, err)
}
1324959
func (err *Error) Error() string {
	return fmt.Sprintf("%s\nRefer to: %s", err.Err.Error(), err.Reference)
}