mongodb / go-client-mongodb-atlas

Go Client for MongoDB Atlas
https://www.mongodb.com/docs/atlas/reference/api-resources-spec/
Apache License 2.0
79 stars 34 forks source link

CLOUDP-171830 general errors #460

Closed wtrocki closed 1 year ago

wtrocki commented 1 year ago

Description

Our API return various different errors that aren't properly specified in the OpenAPI file. For example frequent 406 errors or 410 errors are never declared in OpenAPI. Undeclared error ends up printed as unhelpful "[status code] error"

Thanks to our API using Error object as the general object we can generalize error handling and assume that error model will be always returned. This will improve that errors returned from our API are always handled properly. In cases where errors aren't in Error format (currently all are) we will return generic errors which is nice tradeoff to not recognizing more than half of the error states.

See only first commit and single file from the second.

wtrocki commented 1 year ago

Updated and already fixed all error handling in the CLI:

Error: GET https://cloud-dev.mongodb.com/api/atlas/v1.0/groups/63b6dd17362d4278259cfa25/serverless/32323fse: 404 (request "SERVERLESS_INSTANCE_NOT_FOUND") No serverless instance named 32323fse exists in group 63b6dd17362d4278259cfa25.

Due to mix up (long day) I pushed another fix to that PR. I have enabled removing stale approval for the sdk.