2
votes

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?

1

1 Answers

5
votes

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 { ... }
}