mirror of
https://github.com/chaisql/chai.git
synced 2025-10-05 07:36:56 +08:00
Move parser into parser package
This commit is contained in:
25
errors.go
25
errors.go
@@ -2,10 +2,6 @@ package genji
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/asdine/genji/internal/scanner"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -33,24 +29,3 @@ var (
|
||||
// ErrResultClosed is returned when trying to close an already closed result.
|
||||
ErrResultClosed = errors.New("result already closed")
|
||||
)
|
||||
|
||||
// ParseError represents an error that occurred during parsing.
|
||||
type ParseError struct {
|
||||
Message string
|
||||
Found string
|
||||
Expected []string
|
||||
Pos scanner.Pos
|
||||
}
|
||||
|
||||
// newParseError returns a new instance of ParseError.
|
||||
func newParseError(found string, expected []string, pos scanner.Pos) *ParseError {
|
||||
return &ParseError{Found: found, Expected: expected, Pos: pos}
|
||||
}
|
||||
|
||||
// Error returns the string representation of the error.
|
||||
func (e *ParseError) Error() string {
|
||||
if e.Message != "" {
|
||||
return fmt.Sprintf("%s at line %d, char %d", e.Message, e.Pos.Line+1, e.Pos.Char+1)
|
||||
}
|
||||
return fmt.Sprintf("found %s, expected %s at line %d, char %d", e.Found, strings.Join(e.Expected, ", "), e.Pos.Line+1, e.Pos.Char+1)
|
||||
}
|
||||
|
Reference in New Issue
Block a user