MCPcopy Index your code
hub / github.com/sqlc-dev/sqlc / normalizeErr

Function normalizeErr

internal/engine/dolphin/parse.go:28–49  ·  view source on GitHub ↗
(err error)

Source from the content-addressed store, hash-verified

26var lineColumn = regexp.MustCompile(`^line (\d+) column (\d+) (.*)`)
27
28func normalizeErr(err error) error {
29 if err == nil {
30 return err
31 }
32 parts := strings.Split(err.Error(), "\n")
33 msg := strings.TrimSpace(parts[0] + "\"")
34 out := lineColumn.FindStringSubmatch(msg)
35 if len(out) == 4 {
36 line, lineErr := strconv.Atoi(out[1])
37 col, colErr := strconv.Atoi(out[2])
38 if lineErr != nil || colErr != nil {
39 return errors.New(msg)
40 }
41 return &sqlerr.Error{
42 Message: "syntax error",
43 Err: errors.New(out[3]),
44 Line: line,
45 Column: col,
46 }
47 }
48 return errors.New(msg)
49}
50
51func (p *Parser) Parse(r io.Reader) ([]ast.Statement, error) {
52 blob, err := io.ReadAll(r)

Callers 1

ParseMethod · 0.70

Calls 1

ErrorMethod · 0.45

Tested by

no test coverage detected