// EOFAsNil filtrates errors,
// If err is equal to io.EOF returns nil.
17485
func EOFAsNil(err error) error {
	if terror.ErrorEqual(err, io.EOF) {
		return nil
	}
	return errors.Trace(err)
}
826304
func (resp *Response) BodyNil(msg ...interface{}) *Response {
	resp.assertion.Nil(resp.body, msg...)
	return resp
}
2233
func ErrorInternal(responseWriter http.ResponseWriter, err error) bool {
	return Error(responseWriter, http.StatusInternalServerError, err)
}
949975
func ToFileError(fileType string, err error) FileError {
	for _, handle := range lineNumberExtractors {
		lno, col := handle(err)
		offset, typ := extractOffsetAndType(err)
		if fileType == "" {
			fileType = typ
		}

		if lno > 0 || offset != -1 {
			return NewFileError(fileType, offset, lno, col, err)
		}
	}
	// Fall back to the pointing to line number 1.
	return NewFileError(fileType, -1, 1, 1, err)
}
75645
func EOF(err error) bool {
	if err == io.EOF {
		return true
	}

	if strings.Contains(err.Error(), "closed") {
		return true
	}

	if strings.Contains(err.Error(), "reset by peer") {
		return true
	}

	return false
}
892587
func noeof64(n int64, err error) (int64, error) {
	if err == io.EOF {
		return n, io.ErrUnexpectedEOF
	}
	return n, err
}
530401
func ParseAll(ss ...string) (Filter, error) {
	if len(ss) == 0 {
		return Always, nil
	}

	var fs []Filter
	for _, s := range ss {
		f, err := Parse(s)
		if err != nil {
			return nil, errors.Wrap(errdefs.ErrInvalidArgument, err.Error())
		}

		fs = append(fs, f)
	}

	return Any(fs), nil
}
643284
func ErrorInternal(c web.C, rw http.ResponseWriter, err error) {
	// produce stack backtrace, max 64KB
	const size = 64 << 10 // 64KB
	buf := make([]byte, size)
	buf = buf[:runtime.Stack(buf, false)]
	lines := strings.Split(string(buf), "\n")
	c.Env["stack"] = lines[3:]

	if err != nil {
		ErrorString(c, rw, 500, err.Error())
	} else {
		ErrorString(c, rw, 500, "nil err passed into gojiutil.ErrorInternal")
	}
}
1298933
func CheckEOF(in IndexInput) error {
	if in.FilePointer() != in.Length() {
		return errors.New(fmt.Sprintf(
			"did not read all bytes from file: read %v vs size %v (resources: %v)",
			in.FilePointer(), in.Length(), in))
	}
	return nil
}
281561
func (l ErrorSlice) FirstNonNil() error {
	for _, e := range l {
		if e != nil {
			return e
		}
	}
	return nil
}
169374
func (fo *fo_FO) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
	return locales.PluralRuleUnknown
}
636614
func (rs *Rows) Err() error {
	if rs.lasterr == io.EOF {
		return nil
	}
	return rs.lasterr
}
987429
func ToFileErrorWithOffset(fe FileError, offset int) FileError {
	pos := fe.Position()
	return ToFileErrorWithLineNumber(fe, pos.LineNumber+offset)
}
749556
func (l *Lexer) nextUntilEOF(s string) bool {
	for r := l.next(); r != eof && strings.IndexRune(s, r) < 0; r = l.next() {
		// l.next()
		l.accept()
	}
	if l.r == eof {
		return true
	}
	return false
}
1332936
func (p *Parser) parseFilter(cur *ListNode) error {
	p.pos += len("[?(")
	p.consumeText()
	begin := false
	end := false
	var pair rune

Loop:
	for {
		r := p.next()
		switch r {
		case eof, '\n':
			return fmt.Errorf("unterminated filter")
		case '"', '\'':
			if begin == false {
				//save the paired rune
				begin = true
				pair = r
				continue
			}
			//only add when met paired rune
			if p.input[p.pos-2] != '\\' && r == pair {
				end = true
			}
		case ')':
			//in rightParser below quotes only appear zero or once
			//and must be paired at the beginning and end
			if begin == end {
				break Loop
			}
		}
	}
	if p.next() != ']' {
		return fmt.Errorf("unclosed array expect ]")
	}
	reg := regexp.MustCompile(`^([^!<>=]+)([!<>=]+)(.+?)$`)
	text := p.consumeText()
	text = text[:len(text)-2]
	value := reg.FindStringSubmatch(text)
	if value == nil {
		parser, err := parseAction("text", text)
		if err != nil {
			return err
		}
		cur.append(newFilter(parser.Root, newList(), "exists"))
	} else {
		leftParser, err := parseAction("left", value[1])
		if err != nil {
			return err
		}
		rightParser, err := parseAction("right", value[3])
		if err != nil {
			return err
		}
		cur.append(newFilter(leftParser.Root, rightParser.Root, value[2]))
	}
	return p.parseInsideAction(cur)
}
337586
func (z *StreamLexer) Err() error {
	if z.err == io.EOF && z.pos < len(z.buf) {
		return nil
	}
	return z.err
}
1009359
func IsErrEOF(err error) bool {
	if err == io.EOF {
		return true
	}

	errStr := err.Error()
	if strings.Contains(errStr, yamuxStreamClosed) ||
		strings.Contains(errStr, yamuxSessionShutdown) {
		return true
	}

	return false
}