snapshot of https://github.com/sqlc-dev/sqlc.git (main, 2026-09-16; blobs > 131072B omitted)
Some checks failed
kotlin / test (push) Has been skipped
python / test (push) Has been skipped
typescript / test (push) Has been skipped
go / build darwin/amd64 (push) Has been cancelled
go / build linux/amd64 (push) Has been cancelled
go / build windows/amd64 (push) Has been cancelled
go / build darwin/arm64 (push) Has been cancelled
go / build linux/arm64 (push) Has been cancelled
go / build windows/arm64 (push) Has been cancelled
go / test (push) Has been cancelled
go / vuln_check (push) Has been cancelled
Some checks failed
kotlin / test (push) Has been skipped
python / test (push) Has been skipped
typescript / test (push) Has been skipped
go / build darwin/amd64 (push) Has been cancelled
go / build linux/amd64 (push) Has been cancelled
go / build windows/amd64 (push) Has been cancelled
go / build darwin/arm64 (push) Has been cancelled
go / build linux/arm64 (push) Has been cancelled
go / build windows/arm64 (push) Has been cancelled
go / test (push) Has been cancelled
go / vuln_check (push) Has been cancelled
This commit is contained in:
52
internal/multierr/error.go
Normal file
52
internal/multierr/error.go
Normal file
@@ -0,0 +1,52 @@
|
||||
package multierr
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/sqlc-dev/sqlc/internal/source"
|
||||
"github.com/sqlc-dev/sqlc/internal/sql/sqlerr"
|
||||
)
|
||||
|
||||
type FileError struct {
|
||||
Filename string
|
||||
Line int
|
||||
Column int
|
||||
Err error
|
||||
}
|
||||
|
||||
func (e *FileError) Unwrap() error {
|
||||
return e.Err
|
||||
}
|
||||
|
||||
type Error struct {
|
||||
errs []*FileError
|
||||
}
|
||||
|
||||
func (e *Error) Add(filename, in string, loc int, err error) {
|
||||
line := 1
|
||||
column := 1
|
||||
if lerr, ok := err.(*sqlerr.Error); ok {
|
||||
if lerr.Location != 0 {
|
||||
loc = lerr.Location
|
||||
} else if lerr.Line != 0 && lerr.Column != 0 {
|
||||
line = lerr.Line
|
||||
column = lerr.Column
|
||||
}
|
||||
}
|
||||
if in != "" && loc != 0 {
|
||||
line, column = source.LineNumber(in, loc)
|
||||
}
|
||||
e.errs = append(e.errs, &FileError{filename, line, column, err})
|
||||
}
|
||||
|
||||
func (e *Error) Errs() []*FileError {
|
||||
return e.errs
|
||||
}
|
||||
|
||||
func (e *Error) Error() string {
|
||||
return fmt.Sprintf("multiple errors: %d errors", len(e.errs))
|
||||
}
|
||||
|
||||
func New() *Error {
|
||||
return &Error{}
|
||||
}
|
||||
Reference in New Issue
Block a user