// toErr converts the error to the ErrInfoSchemaChanged when the schema is outdated.
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
}
58256
func checkErr(err error, handleErr func(string, int)) {
	switch err.(type) {
	case nil:
		return
	case preflightError:
		handleErr(err.Error(), PreFlightExitCode)
	case errorsutil.Aggregate:
		handleErr(err.Error(), ValidationExitCode)

	default:
		handleErr(err.Error(), DefaultErrorExitCode)
	}
}
857305
func ToError(err error) error {
	switch e := err.(type) {
	case *cli.ExitError:
		return e
	case nil:
		return nil
	default:
		return cli.NewExitError(err.Error(), -1)
	}
}
281707
func (s *State) Err() error {
	if s.ErrorMsg != "" {
		return errors.New(s.ErrorMsg)
	}
	return nil
}
9753
func (lex *GotestLexer) Err() error {
	if lex.err != nil {
		return lex.err
	}
	return lex.scanner.Err()
}
923506
func (t *Tomb) Err() (reason error) {
	t.init()
	t.m.Lock()
	reason = t.reason
	t.m.Unlock()
	return
}
512141
func NewErr(errCode uint16, args ...interface{}) *SQLError {
	e := &SQLError{Code: errCode}

	if s, ok := MySQLState[errCode]; ok {
		e.State = s
	} else {
		e.State = DefaultMySQLState
	}

	if format, ok := MySQLErrName[errCode]; ok {
		e.Message = fmt.Sprintf(format, args...)
	} else {
		e.Message = fmt.Sprint(args...)
	}

	return e
}
1321237
func (s *Segmenter) Err() error {
	if s.err == io.EOF {
		return nil
	}
	return s.err
}
55228
func NotError(t testing.TB, expr interface{}, args ...interface{}) {
	if IsNil(expr) { // 空值必定没有错误
		assert(t, true, args, []interface{}{"NotError 失败，实际类型为[%T]", expr})
		return
	}
	err, ok := expr.(error)
	assert(t, !ok, args, []interface{}{"NotError 失败，错误信息为[%v]", err})
}
949844
func (tr Row) UintErr(nn int) (val uint, err error) {
	switch data := tr[nn].(type) {
	case nil:
		// nop
	case uint32:
		val = uint(data)
	case uint16:
		val = uint(data)
	case uint8:
		val = uint(data)
	case []byte:
		var v uint64
		v, err = strconv.ParseUint(string(data), 0, 0)
		val = uint(v)
	case *[]byte:
		var v uint64
		v, err = strconv.ParseUint(string(*data), 0, 0)
		val = uint(v)
	case uint64:
		if data <= _MAX_UINT {
			val = uint(data)
		} else {
			err = strconv.ErrRange
		}
	case int8, int16, int32, int64:
		v := reflect.ValueOf(data).Int()
		if v >= 0 && uint64(v) <= _MAX_UINT {
			val = uint(v)
		} else {
			err = strconv.ErrRange
		}
	default:
		err = os.ErrInvalid
	}
	return
}
1246979
func (parser *Parser) err() error {
	if parser.tokenError() {
		token := parser.nextToken()
		return fmt.Errorf("Tokenizer error: %s", token.String())
	}

	return nil
}
528042
func (it *ScanIterator) Err() error {
	it.mu.Lock()
	err := it.cmd.Err()
	it.mu.Unlock()
	return err
}
485222
func Err(format string, a ...interface{}) error {
	p := message.NewPrinter(preferredLanguage)
	if errFile == nil {
		if _, err := p.Fprintf(os.Stderr, "(stderr unset)"+format, a...); err != nil {
			return err
		}
		return fmt.Errorf("no error file has been set")
	}
	_, err := p.Fprintf(errFile, format, a...)
	return err
}
805396
func NewTrie(options ...Option) *Trie {
	trie := &Trie{}

	for _, opt := range options {
		opt(trie)
	}

	if trie.maxPrefixPerNode <= 0 {
		trie.maxPrefixPerNode = DefaultMaxPrefixPerNode
	}
	if trie.maxChildrenPerSparseNode <= 0 {
		trie.maxChildrenPerSparseNode = DefaultMaxChildrenPerSparseNode
	}

	trie.children = newSparseChildList(trie.maxChildrenPerSparseNode)
	return trie
}
629470
func (m *Manager) errf(s string, v ...interface{}) error {
	err := fmt.Errorf(s, v...)
	if m.Errorf == nil {
		m.log("ERROR: %v", err)
	} else {
		m.Errorf(s, v)
	}
	return err
}
1196997
func (d *Decoder) Err() error {
	if d.err == io.EOF {
		return nil
	}
	return d.err
}
75028
func (r *rudimentaryErrorBackoff) OnError(error) {
	r.lastErrorTimeLock.Lock()
	defer r.lastErrorTimeLock.Unlock()
	d := time.Since(r.lastErrorTime)
	if d < r.minPeriod {
		// If the time moves backwards for any reason, do nothing
		time.Sleep(r.minPeriod - d)
	}
	r.lastErrorTime = time.Now()
}