{"action":"created","issue":{"url":"https://api.github.com/repos/dancannon/gorethink/issues/253","labels_url":"https://api.github.com/repos/dancannon/gorethink/issues/253/labels{/name}","comments_url":"https://api.github.com/repos/dancannon/gorethink/issues/253/comments","events_url":"https://api.github.com/repos/dancannon/gorethink/issues/253/events","html_url":"https://github.com/dancannon/gorethink/issues/253","id":123662328,"number":253,"title":"Feature request: Ability to identify returned Error identities from RethinkDB to Golang domain","user":{"login":"eliezedeck","id":7553916,"avatar_url":"https://avatars.githubusercontent.com/u/7553916?v=3","gravatar_id":"","url":"https://api.github.com/users/eliezedeck","html_url":"https://github.com/eliezedeck","followers_url":"https://api.github.com/users/eliezedeck/followers","following_url":"https://api.github.com/users/eliezedeck/following{/other_user}","gists_url":"https://api.github.com/users/eliezedeck/gists{/gist_id}","starred_url":"https://api.github.com/users/eliezedeck/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eliezedeck/subscriptions","organizations_url":"https://api.github.com/users/eliezedeck/orgs","repos_url":"https://api.github.com/users/eliezedeck/repos","events_url":"https://api.github.com/users/eliezedeck/events{/privacy}","received_events_url":"https://api.github.com/users/eliezedeck/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/dancannon/gorethink/labels/p:medium","name":"p:medium","color":"eb6420"},{"url":"https://api.github.com/repos/dancannon/gorethink/labels/t:enhancement","name":"t:enhancement","color":"4AE371"}],"state":"open","locked":false,"assignee":{"login":"dancannon","id":414768,"avatar_url":"https://avatars.githubusercontent.com/u/414768?v=3","gravatar_id":"","url":"https://api.github.com/users/dancannon","html_url":"https://github.com/dancannon","followers_url":"https://api.github.com/users/dancannon/followers","following_url":"https://api.github.com/users/dancannon/following{/other_user}","gists_url":"https://api.github.com/users/dancannon/gists{/gist_id}","starred_url":"https://api.github.com/users/dancannon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dancannon/subscriptions","organizations_url":"https://api.github.com/users/dancannon/orgs","repos_url":"https://api.github.com/users/dancannon/repos","events_url":"https://api.github.com/users/dancannon/events{/privacy}","received_events_url":"https://api.github.com/users/dancannon/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/dancannon/gorethink/milestones/7","html_url":"https://github.com/dancannon/gorethink/milestones/v1.3.0","labels_url":"https://api.github.com/repos/dancannon/gorethink/milestones/7/labels","id":1428977,"number":7,"title":"v1.3.0","description":"","creator":{"login":"dancannon","id":414768,"avatar_url":"https://avatars.githubusercontent.com/u/414768?v=3","gravatar_id":"","url":"https://api.github.com/users/dancannon","html_url":"https://github.com/dancannon","followers_url":"https://api.github.com/users/dancannon/followers","following_url":"https://api.github.com/users/dancannon/following{/other_user}","gists_url":"https://api.github.com/users/dancannon/gists{/gist_id}","starred_url":"https://api.github.com/users/dancannon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dancannon/subscriptions","organizations_url":"https://api.github.com/users/dancannon/orgs","repos_url":"https://api.github.com/users/dancannon/repos","events_url":"https://api.github.com/users/dancannon/events{/privacy}","received_events_url":"https://api.github.com/users/dancannon/received_events","type":"User","site_admin":false},"open_issues":1,"closed_issues":0,"state":"open","created_at":"2015-11-25T09:56:04Z","updated_at":"2015-12-23T14:43:28Z","due_on":null,"closed_at":null},"comments":1,"created_at":"2015-12-23T13:44:22Z","updated_at":"2016-01-11T21:08:08Z","closed_at":null,"body":"At this time, the returned `error` object doesn't offer the ability to identify the kind of the error. Because of this, one needs to manually test the error string if it contains a specific set of strings, for example (testing if the error mentions about Table or Database already existing):\r\n```go\r\nif strings.Contains(err.Error(), \"already exists\") {\r\n  // I may choose to ignore errors about stuffs already existing\r\n}\r\n```\r\n\r\nThis is error-prone and it's easy to mistake the comparison string. Not only that, but the RethinkDB team may decide in the future that the message needs to be changed and all programs relying on the message to contain that specific \"already exists\" string will all fail silently.\r\n\r\nAs mentioned on Gitter by @dancannon himself, the error from RethinkDB contains an \"e\" field which is likely to be the unique error identifier code. This field provides several benefits:\r\n\r\n- Accurate identity of the error and could possibly identify the difference between a Database already existing and a Table already existing\r\n- Easier to compare to, rather than involving memory compare for strings comparison.\r\n- Has a lower probability of change because it's likely deep from the C++ RethinkDB API.\r\n\r\nThere needs to be a way to be able to get detailed information about this error up to Golang domain."},"comment":{"url":"https://api.github.com/repos/dancannon/gorethink/issues/comments/170690222","html_url":"https://github.com/dancannon/gorethink/issues/253#issuecomment-170690222","issue_url":"https://api.github.com/repos/dancannon/gorethink/issues/253","id":170690222,"user":{"login":"dancannon","id":414768,"avatar_url":"https://avatars.githubusercontent.com/u/414768?v=3","gravatar_id":"","url":"https://api.github.com/users/dancannon","html_url":"https://github.com/dancannon","followers_url":"https://api.github.com/users/dancannon/followers","following_url":"https://api.github.com/users/dancannon/following{/other_user}","gists_url":"https://api.github.com/users/dancannon/gists{/gist_id}","starred_url":"https://api.github.com/users/dancannon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dancannon/subscriptions","organizations_url":"https://api.github.com/users/dancannon/orgs","repos_url":"https://api.github.com/users/dancannon/repos","events_url":"https://api.github.com/users/dancannon/events{/privacy}","received_events_url":"https://api.github.com/users/dancannon/received_events","type":"User","site_admin":false},"created_at":"2016-01-11T21:08:08Z","updated_at":"2016-01-11T21:08:08Z","body":"This should now be fixed in v1.3.0. I implemented the same error types as in the official drivers. This allows you to do a type switch to check which error is returned."}}