Skip to content

Commit f21fd26

Browse files
Add IsExternalStorageError to check for external storage errors. (#458)
1 parent a4dd5c0 commit f21fd26

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## [master](https://github.com/arangodb/go-driver/tree/master) (N/A)
44
- Use Go 1.19.4
5+
- Add `IsExternalStorageError` to check for [external storage errors](https://www.arangodb.com/docs/stable/appendix-error-codes.html#external-arangodb-storage-errors).
56

67
## [1.4.1](https://github.com/arangodb/go-driver/tree/v1.4.1) (2022-12-14)
78
- Add support for `checksum` in Collections

error.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,13 @@ const (
4444
// Internal ArangoDB storage errors
4545
ErrArangoReadOnly = 1004
4646

47+
// External ArangoDB storage errors
48+
ErrArangoCorruptedDatafile = 1100
49+
ErrArangoIllegalParameterFile = 1101
50+
ErrArangoCorruptedCollection = 1102
51+
ErrArangoFileSystemFull = 1104
52+
ErrArangoDataDirLocked = 1107
53+
4754
// General ArangoDB storage errors
4855
ErrArangoConflict = 1200
4956
ErrArangoDocumentNotFound = 1202
@@ -167,6 +174,18 @@ func IsDataSourceOrDocumentNotFound(err error) bool {
167174
IsArangoErrorWithErrorNum(err, ErrArangoDocumentNotFound, ErrArangoDataSourceNotFound)
168175
}
169176

177+
// IsExternalStorageError returns true if ArangoDB is having an error with accessing or writing to storage.
178+
func IsExternalStorageError(err error) bool {
179+
return IsArangoErrorWithErrorNum(
180+
err,
181+
ErrArangoCorruptedDatafile,
182+
ErrArangoIllegalParameterFile,
183+
ErrArangoCorruptedCollection,
184+
ErrArangoFileSystemFull,
185+
ErrArangoDataDirLocked,
186+
)
187+
}
188+
170189
// IsConflict returns true if the given error is an ArangoError with code 409, indicating a conflict.
171190
func IsConflict(err error) bool {
172191
return IsArangoErrorWithCode(err, http.StatusConflict) || IsArangoErrorWithErrorNum(err, ErrUserDuplicate)

0 commit comments

Comments
 (0)