This repository has been archived by the owner on Sep 9, 2024. It is now read-only.
forked from gocassa/gocassa
-
Notifications
You must be signed in to change notification settings - Fork 13
/
errors.go
38 lines (33 loc) · 1.45 KB
/
errors.go
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 gocassa
import (
"context"
"fmt"
"strings"
)
// RowNotFoundError is returned by Reads if the Row is not found.
type RowNotFoundError struct {
file string
line int
}
func (r RowNotFoundError) Error() string {
ss := strings.Split(r.file, "/")
f := ""
if len(ss) > 0 {
f = ss[len(ss)-1]
}
return fmt.Sprintf("%v:%v: No rows returned", f, r.line)
}
// errOp is an Op which represents a known error, which will always return during preflighting (preventing any execution
// in a multiOp scenario)
type errOp struct{ err error }
func (o errOp) Run() error { return o.err }
func (o errOp) RunWithContext(_ context.Context) error { return o.err }
func (o errOp) RunAtomically() error { return o.err }
func (o errOp) RunAtomicallyWithContext(_ context.Context) error { return o.err }
func (o errOp) RunLoggedBatchWithContext(_ context.Context) error { return o.err }
func (o errOp) Add(ops ...Op) Op { return multiOp{o}.Add(ops...) }
func (o errOp) Options() Options { return Options{} }
func (o errOp) WithOptions(_ Options) Op { return o }
func (o errOp) Preflight() error { return o.err }
func (o errOp) GenerateStatement() Statement { return noOpStatement{} }
func (o errOp) QueryExecutor() QueryExecutor { return nil }