ND003
ND003

Reputation: 802

Google Cloud Storage GoLang : Error Handling

I'm using the Golang Client Library for Google Cloud Storage to fetch and retrieve data from Google Bucket.

But I cannot find a way to do some error handling. The SDK returns some strings and there is no documentation around that. It would have been good if they sent error codes.

This page https://cloud.google.com/appengine/docs/standard/go/googlecloudstorageclient/errors talks about only 2 errors.

Perhaps, I'm missing something. Is it possible to get error codes?

Upvotes: 2

Views: 3439

Answers (1)

blobdon
blobdon

Reputation: 1336

From documentation for Google Cloud Storage Client package

Errors returned by this client are often of the type googleapi.Error. These errors can be introspected for more information by type asserting to the richer googleapi.Error type. For example:

if e, ok := err.(*googleapi.Error); ok {
    if e.Code == 409 { ... }
}

Upvotes: 8

Related Questions