Repository navigation
Expand file tree
/
Copy patherror.go
More file actions
103 lines (92 loc) · 2.6 KB
/
Copy patherror.go
File metadata and controls
103 lines (92 loc) · 2.6 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
package sqlite3vfs
import "fmt"
type sqliteError struct {
code int
text string
}
func (e sqliteError) Error() string {
return fmt.Sprintf("sqlite (%d) %s", e.code, e.text)
}
// https://www.sqlite.org/rescode.html
const (
sqliteOK = 0
)
var (
GenericError = sqliteError{1, "Generic Error"}
InternalError = sqliteError{2, "Internal Error"}
PermError = sqliteError{3, "Perm Error"}
AbortError = sqliteError{4, "Abort Error"}
BusyError = sqliteError{5, "Busy Error"}
LockedError = sqliteError{6, "Locked Error"}
NoMemError = sqliteError{7, "No Mem Error"}
ReadOnlyError = sqliteError{8, "Read Only Error"}
InterruptError = sqliteError{9, "Interrupt Error"}
IOError = sqliteError{10, "IO Error"}
CorruptError = sqliteError{11, "Corrupt Error"}
NotFoundError = sqliteError{12, "Not Found Error"}
FullError = sqliteError{13, "Full Error"}
CantOpenError = sqliteError{14, "CantOpen Error"}
ProtocolError = sqliteError{15, "Protocol Error"}
EmptyError = sqliteError{16, "Empty Error"}
SchemaError = sqliteError{17, "Schema Error"}
TooBigError = sqliteError{18, "TooBig Error"}
ConstraintError = sqliteError{19, "Constraint Error"}
MismatchError = sqliteError{20, "Mismatch Error"}
MisuseError = sqliteError{21, "Misuse Error"}
NoLFSError = sqliteError{22, "No Large File Support Error"}
AuthError = sqliteError{23, "Auth Error"}
FormatError = sqliteError{24, "Format Error"}
RangeError = sqliteError{25, "Range Error"}
NotaDBError = sqliteError{26, "Not a DB Error"}
NoticeError = sqliteError{27, "Notice Error"}
WarningError = sqliteError{28, "Warning Error"}
IOErrorRead = sqliteError{266, "IO Error Read"}
IOErrorShortRead = sqliteError{522, "IO Error Short Read"}
IOErrorWrite = sqliteError{778, "IO Error Write"}
)
var errMap = map[int]sqliteError{
1: GenericError,
2: InternalError,
3: PermError,
4: AbortError,
5: BusyError,
6: LockedError,
7: NoMemError,
8: ReadOnlyError,
9: InterruptError,
10: IOError,
11: CorruptError,
12: NotFoundError,
13: FullError,
14: CantOpenError,
15: ProtocolError,
16: EmptyError,
17: SchemaError,
18: TooBigError,
19: ConstraintError,
20: MismatchError,
21: MisuseError,
22: NoLFSError,
23: AuthError,
24: FormatError,
25: RangeError,
26: NotaDBError,
27: NoticeError,
28: WarningError,
266: IOErrorRead,
522: IOErrorShortRead,
778: IOErrorWrite,
}
func errFromCode(code int) error {
if code == 0 {
return nil
}
err, ok := errMap[code]
if ok {
return err
}
return sqliteError{
code: code,
text: "unknown err code",
}
}