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 v2/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- Adjust Cursor options
- Switch to Go 1.22.8
- Remove deprecated context functions
- Fix Error Handler in CreateCollectionWithOptions

## [2.1.1](https://github.com/arangodb/go-driver/tree/v2.1.1) (2024-09-27)
- Improve backup tests stability
Expand Down
9 changes: 5 additions & 4 deletions v2/arangodb/database_collection_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,15 +122,16 @@ func (d databaseCollection) CreateCollectionWithOptions(ctx context.Context, nam

urlEndpoint := d.db.url("_api", "collection")
reqData := struct {
shared.ResponseStruct `json:",inline"`
Name string `json:"name"`
Name string `json:"name"`
*CreateCollectionProperties
}{
Name: name,
CreateCollectionProperties: props,
}

resp, err := connection.CallPost(ctx, d.db.connection(), urlEndpoint, nil, &reqData, append(d.db.modifiers, options.modifyRequest)...)
var respData shared.ResponseStruct

resp, err := connection.CallPost(ctx, d.db.connection(), urlEndpoint, &respData, &reqData, append(d.db.modifiers, options.modifyRequest)...)
if err != nil {
return nil, errors.WithStack(err)
}
Expand All @@ -139,6 +140,6 @@ func (d databaseCollection) CreateCollectionWithOptions(ctx context.Context, nam
case http.StatusOK:
return newCollection(d.db, name), nil
default:
return nil, reqData.AsArangoErrorWithCode(code)
return nil, respData.AsArangoErrorWithCode(code)
}
}
5 changes: 5 additions & 0 deletions v2/arangodb/shared/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ func (ae ArangoError) Error() string {
return fmt.Sprintf("ArangoError: Code %d, ErrorNum %d", ae.Code, ae.ErrorNum)
}

// FullError returns the full error message of an ArangoError.
func (ae ArangoError) FullError() string {
return fmt.Sprintf("ArangoError: Code %d, ErrorNum %d: %s", ae.Code, ae.ErrorNum, ae.ErrorMessage)
}

// Timeout returns true when the given error is a timeout error.
func (ae ArangoError) Timeout() bool {
return ae.HasError && (ae.Code == http.StatusRequestTimeout || ae.Code == http.StatusGatewayTimeout)
Expand Down