-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy patherrors.go
More file actions
38 lines (32 loc) · 745 Bytes
/
errors.go
File metadata and controls
38 lines (32 loc) · 745 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package sol
import (
"errors"
"fmt"
"strings"
)
// ErrNoColumns is returned when attempting to compile a query without
// any columns
var ErrNoColumns = errors.New(
"sol: cannot compile a statement without columns",
)
type fieldError struct {
column string
table string
clause string
}
type stmtErrors struct {
meta []string
fields map[fieldError]string
}
// Error implements the error interface
func (e stmtErrors) Error() string {
errs := e.meta
for field, err := range e.fields {
errs = append(errs, fmt.Sprintf("%s (%s)", err, field))
}
return strings.Join(errs, "; ")
}
// Exist returns true if there are either meta or fields errors
func (e stmtErrors) Exist() bool {
return len(e.meta) > 0 || len(e.fields) > 0
}