Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 19 additions & 0 deletions error.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down