diff --git a/CHANGELOG.md b/CHANGELOG.md index 088f9e4e..6b5c28f8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## [master](https://github.com/arangodb/go-driver/tree/master) (N/A) - Use Go 1.19.4 +- Add `IsExternalStorageError` to check for [external storage errors](https://www.arangodb.com/docs/stable/appendix-error-codes.html#external-arangodb-storage-errors). ## [1.4.1](https://github.com/arangodb/go-driver/tree/v1.4.1) (2022-12-14) - Add support for `checksum` in Collections diff --git a/error.go b/error.go index 576d8904..653b23a6 100644 --- a/error.go +++ b/error.go @@ -44,6 +44,13 @@ const ( // Internal ArangoDB storage errors ErrArangoReadOnly = 1004 + // External ArangoDB storage errors + ErrArangoCorruptedDatafile = 1100 + ErrArangoIllegalParameterFile = 1101 + ErrArangoCorruptedCollection = 1102 + ErrArangoFileSystemFull = 1104 + ErrArangoDataDirLocked = 1107 + // General ArangoDB storage errors ErrArangoConflict = 1200 ErrArangoDocumentNotFound = 1202 @@ -167,6 +174,18 @@ func IsDataSourceOrDocumentNotFound(err error) bool { IsArangoErrorWithErrorNum(err, ErrArangoDocumentNotFound, ErrArangoDataSourceNotFound) } +// IsExternalStorageError returns true if ArangoDB is having an error with accessing or writing to storage. +func IsExternalStorageError(err error) bool { + return IsArangoErrorWithErrorNum( + err, + ErrArangoCorruptedDatafile, + ErrArangoIllegalParameterFile, + ErrArangoCorruptedCollection, + ErrArangoFileSystemFull, + ErrArangoDataDirLocked, + ) +} + // IsConflict returns true if the given error is an ArangoError with code 409, indicating a conflict. func IsConflict(err error) bool { return IsArangoErrorWithCode(err, http.StatusConflict) || IsArangoErrorWithErrorNum(err, ErrUserDuplicate)