-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherrors.go
More file actions
88 lines (81 loc) · 2.87 KB
/
Copy patherrors.go
File metadata and controls
88 lines (81 loc) · 2.87 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
package oro
import (
"errors"
"fmt"
)
var (
ErrInvalidArgument = errors.New("oro: invalid argument")
ErrInvalidQuery = errors.New("oro: invalid query")
ErrUnknownField = errors.New("oro: unknown field")
ErrUnknownRelation = errors.New("oro: unknown relation")
ErrRelationNotLoaded = errors.New("oro: relation not loaded")
ErrUnsafeUpdate = errors.New("oro: unsafe update")
ErrUnsafeDelete = errors.New("oro: unsafe delete")
ErrScan = errors.New("oro: scan error")
ErrHook = errors.New("oro: hook error")
ErrEvent = errors.New("oro: event error")
ErrConflict = errors.New("oro: conflict")
ErrConstraint = errors.New("oro: constraint violation")
ErrTransactionRequired = errors.New("oro: transaction required")
ErrTransactionConnection = errors.New("oro: transaction connection mismatch")
ErrStaleData = errors.New("oro: stale data")
ErrUnknownConnection = errors.New("oro: unknown connection")
ErrCrossConnectionQuery = errors.New("oro: cross connection query")
ErrTenantRequired = errors.New("oro: tenant required")
ErrUnknownTenant = errors.New("oro: unknown tenant")
ErrShardRequired = errors.New("oro: shard required")
ErrShardNotFound = errors.New("oro: shard not found")
ErrShardConflict = errors.New("oro: shard conflict")
ErrCrossShardJoin = errors.New("oro: cross shard join")
ErrCrossShardTransaction = errors.New("oro: cross shard transaction")
ErrCacheStoreRequired = errors.New("oro: cache store required")
ErrCacheKeyRequired = errors.New("oro: cache key required")
ErrOrderRequired = errors.New("oro: order required")
ErrClosed = errors.New("oro: closed")
ErrDeadlock = errors.New("oro: deadlock")
ErrSerializationFailure = errors.New("oro: serialization failure")
ErrUnsafeSchemaChange = errors.New("oro: unsafe schema change")
ErrAmbiguousSchemaChange = errors.New("oro: ambiguous schema change")
ErrUnsupported = errors.New("oro: unsupported")
)
type Error struct {
Op string
Kind error
Model string
Table string
Field string
Relation string
SQL string
Args []any
Cause error
}
func (err *Error) Error() string {
if err == nil {
return "<nil>"
}
if err.Cause != nil {
return fmt.Sprintf("%s: %v: %v", err.Op, err.Kind, err.Cause)
}
if err.Kind != nil {
return fmt.Sprintf("%s: %v", err.Op, err.Kind)
}
return err.Op
}
func (err *Error) Unwrap() error {
if err == nil {
return nil
}
return err.Cause
}
func (err *Error) Is(target error) bool {
if err == nil {
return false
}
return errors.Is(err.Kind, target)
}
func wrapError(op string, kind error, cause error) error {
if cause == nil && kind == nil {
return nil
}
return &Error{Op: op, Kind: kind, Cause: cause}
}