diff --git a/v2/CHANGELOG.md b/v2/CHANGELOG.md index 7fcfe437..73dbc208 100644 --- a/v2/CHANGELOG.md +++ b/v2/CHANGELOG.md @@ -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 diff --git a/v2/arangodb/database_collection_impl.go b/v2/arangodb/database_collection_impl.go index 03d6ee87..d447c0f5 100644 --- a/v2/arangodb/database_collection_impl.go +++ b/v2/arangodb/database_collection_impl.go @@ -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) } @@ -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) } } diff --git a/v2/arangodb/shared/error.go b/v2/arangodb/shared/error.go index 5413541f..2bea1186 100644 --- a/v2/arangodb/shared/error.go +++ b/v2/arangodb/shared/error.go @@ -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)