duangong1979 2018-12-14 10:32
浏览 88
已采纳

Google Cloud Storage GoLang:错误处理

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条回答 默认 最新

  • duanguan5922 2018-12-14 16:30
    关注

    From documentation for Google Cloud Storage Client package

    Errors returned by this client are often of the type [googleapi.Error](https://godoc.org/google.golang.org/api/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 { ... }
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥50 adb连接不到手机是怎么回事?
  • ¥15 vs2022无法联网
  • ¥15 TCP的客户端和服务器的互联
  • ¥15 VB.NET操作免驱摄像头
  • ¥15 笔记本上移动热点开关状态查询
  • ¥85 类鸟群Boids——仿真鸟群避障的相关问题
  • ¥15 CFEDEM自带算例错误,如何解决?
  • ¥15 有没有会使用flac3d软件的家人
  • ¥20 360摄像头无法解绑使用,请教解绑当前账号绑定问题,
  • ¥15 docker实践项目