{"action":"created","issue":{"url":"https://api.github.com/repos/coreos/etcd/issues/5481","repository_url":"https://api.github.com/repos/coreos/etcd","labels_url":"https://api.github.com/repos/coreos/etcd/issues/5481/labels{/name}","comments_url":"https://api.github.com/repos/coreos/etcd/issues/5481/comments","events_url":"https://api.github.com/repos/coreos/etcd/issues/5481/events","html_url":"https://github.com/coreos/etcd/issues/5481","id":157321778,"number":5481,"title":"V3 error detecting is difficult","user":{"login":"purpleidea","id":135091,"avatar_url":"https://avatars.githubusercontent.com/u/135091?v=3","gravatar_id":"","url":"https://api.github.com/users/purpleidea","html_url":"https://github.com/purpleidea","followers_url":"https://api.github.com/users/purpleidea/followers","following_url":"https://api.github.com/users/purpleidea/following{/other_user}","gists_url":"https://api.github.com/users/purpleidea/gists{/gist_id}","starred_url":"https://api.github.com/users/purpleidea/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/purpleidea/subscriptions","organizations_url":"https://api.github.com/users/purpleidea/orgs","repos_url":"https://api.github.com/users/purpleidea/repos","events_url":"https://api.github.com/users/purpleidea/events{/privacy}","received_events_url":"https://api.github.com/users/purpleidea/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":12,"created_at":"2016-05-28T05:28:41Z","updated_at":"2016-05-30T05:22:24Z","closed_at":"2016-05-28T05:46:33Z","body":"A number of public API's return errors, which is very useful, however it is difficult or impossible to match on errors without importing lots of packages or often is only possible with string parsing. Visually the errors are fine, but I'd like to programatically detect things and respond accordingly.\r\n\r\nI wish I had an exhaustive list, but I don't. The latest example was:\r\n\r\n    _, err := MemberRemove(context.Background(), mID)\r\n\r\nerr is NOT a\r\n\r\n    etcdserver/membership ErrIDNotFound\r\n\r\nas I would have expected. I also tried a\r\n\r\n    etcdserver/api/v3rpc/rpctypes ErrGRPCMemberNotFound\r\n\r\nafter I searched through the code.\r\n\r\nTurned out %T says it's an\r\n\r\n    rpctypes.EtcdError\r\n\r\nI eventually had to\r\n\r\n    e, ok := err.(rpctypes.EtcdError)\r\n    e.Code() == codes.NotFound ...\r\n\r\nI really hope there is a better way, or that someone could consider something for the code base. Some other types of errors are actually private, therefore matching is actually impossible without string parsing.\r\n\r\nI'm also happy to contribute some code to this effort if someone wants to help guide it.\r\n\r\nThanks!"},"comment":{"url":"https://api.github.com/repos/coreos/etcd/issues/comments/222413582","html_url":"https://github.com/coreos/etcd/issues/5481#issuecomment-222413582","issue_url":"https://api.github.com/repos/coreos/etcd/issues/5481","id":222413582,"user":{"login":"gyuho","id":6799218,"avatar_url":"https://avatars.githubusercontent.com/u/6799218?v=3","gravatar_id":"","url":"https://api.github.com/users/gyuho","html_url":"https://github.com/gyuho","followers_url":"https://api.github.com/users/gyuho/followers","following_url":"https://api.github.com/users/gyuho/following{/other_user}","gists_url":"https://api.github.com/users/gyuho/gists{/gist_id}","starred_url":"https://api.github.com/users/gyuho/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gyuho/subscriptions","organizations_url":"https://api.github.com/users/gyuho/orgs","repos_url":"https://api.github.com/users/gyuho/repos","events_url":"https://api.github.com/users/gyuho/events{/privacy}","received_events_url":"https://api.github.com/users/gyuho/received_events","type":"User","site_admin":false},"created_at":"2016-05-30T05:22:24Z","updated_at":"2016-05-30T05:22:24Z","body":"For that I think you need to `grpc.ErrorDesc(err) == etcdserver.ErrStopped.String()`"}}
{"actor":{"display_login":"gyuho"}}