Skip to content

Commit 16eae82

Browse files
committed
[Feature] [V2] Fix Error Message for CreateCollectionWithOptions
1 parent 5e75d1d commit 16eae82

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

v2/arangodb/database_collection_impl.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,15 +122,16 @@ func (d databaseCollection) CreateCollectionWithOptions(ctx context.Context, nam
122122

123123
urlEndpoint := d.db.url("_api", "collection")
124124
reqData := struct {
125-
shared.ResponseStruct `json:",inline"`
126-
Name string `json:"name"`
125+
Name string `json:"name"`
127126
*CreateCollectionProperties
128127
}{
129128
Name: name,
130129
CreateCollectionProperties: props,
131130
}
132131

133-
resp, err := connection.CallPost(ctx, d.db.connection(), urlEndpoint, nil, &reqData, append(d.db.modifiers, options.modifyRequest)...)
132+
var respData shared.ResponseStruct
133+
134+
resp, err := connection.CallPost(ctx, d.db.connection(), urlEndpoint, &respData, &reqData, append(d.db.modifiers, options.modifyRequest)...)
134135
if err != nil {
135136
return nil, errors.WithStack(err)
136137
}
@@ -139,6 +140,6 @@ func (d databaseCollection) CreateCollectionWithOptions(ctx context.Context, nam
139140
case http.StatusOK:
140141
return newCollection(d.db, name), nil
141142
default:
142-
return nil, reqData.AsArangoErrorWithCode(code)
143+
return nil, respData.AsArangoErrorWithCode(code)
143144
}
144145
}

v2/arangodb/shared/error.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,11 @@ func (ae ArangoError) Error() string {
8282
return fmt.Sprintf("ArangoError: Code %d, ErrorNum %d", ae.Code, ae.ErrorNum)
8383
}
8484

85+
// FullError returns the full error message of an ArangoError.
86+
func (ae ArangoError) FullError() string {
87+
return fmt.Sprintf("ArangoError: Code %d, ErrorNum %d: %s", ae.Code, ae.ErrorNum, ae.ErrorMessage)
88+
}
89+
8590
// Timeout returns true when the given error is a timeout error.
8691
func (ae ArangoError) Timeout() bool {
8792
return ae.HasError && (ae.Code == http.StatusRequestTimeout || ae.Code == http.StatusGatewayTimeout)

0 commit comments

Comments
 (0)