{"action":"created","issue":{"url":"https://api.github.com/repos/gorilla/securecookie/issues/24","labels_url":"https://api.github.com/repos/gorilla/securecookie/issues/24/labels{/name}","comments_url":"https://api.github.com/repos/gorilla/securecookie/issues/24/comments","events_url":"https://api.github.com/repos/gorilla/securecookie/issues/24/events","html_url":"https://github.com/gorilla/securecookie/pull/24","id":94182031,"number":24,"title":"Make errors more distinguishable","user":{"login":"keunwoo","id":773433,"avatar_url":"https://avatars.githubusercontent.com/u/773433?v=3","gravatar_id":"","url":"https://api.github.com/users/keunwoo","html_url":"https://github.com/keunwoo","followers_url":"https://api.github.com/users/keunwoo/followers","following_url":"https://api.github.com/users/keunwoo/following{/other_user}","gists_url":"https://api.github.com/users/keunwoo/gists{/gist_id}","starred_url":"https://api.github.com/users/keunwoo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/keunwoo/subscriptions","organizations_url":"https://api.github.com/users/keunwoo/orgs","repos_url":"https://api.github.com/users/keunwoo/repos","events_url":"https://api.github.com/users/keunwoo/events{/privacy}","received_events_url":"https://api.github.com/users/keunwoo/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-07-10T00:32:50Z","updated_at":"2015-07-10T21:24:29Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/gorilla/securecookie/pulls/24","html_url":"https://github.com/gorilla/securecookie/pull/24","diff_url":"https://github.com/gorilla/securecookie/pull/24.diff","patch_url":"https://github.com/gorilla/securecookie/pull/24.patch"},"body":"Prior to this commit, this library raised errors either mostly using\r\nerrors.New() or directly passing through error values from underlying\r\nlibraries.  This made it difficult for clients to respond correctly to\r\nthe errors that were returned.\r\n\r\nThis becomes particularly problematic when securecookie is used together\r\nwith gorilla/sessions.  From an operations standpoint, you often want to\r\nlog different errors when the client simply provides an invalid auth\r\ncookie, versus an I/O error fetching data from the session store.  The\r\nformer probably indicates an expired timestamp or similar client error;\r\nthe latter indicates a possible failure in a backend database.\r\n\r\nThis commit introduces a public Error type, which is now returned\r\nconsistently on all errors, as well as an ErrorType enum, which can be\r\nused to distinguish between implementation errors (UsageError and\r\nInternalError) and failed validation of user input (DecodeError).\r\n\r\nSee also discussion on pull request #9:\r\nhttps://github.com/gorilla/securecookie/pull/9\r\n\r\nSome interface comments on API functions have been clarified and updated\r\nto harmonize with the new error interfaces."},"comment":{"url":"https://api.github.com/repos/gorilla/securecookie/issues/comments/120532766","html_url":"https://github.com/gorilla/securecookie/pull/24#issuecomment-120532766","issue_url":"https://api.github.com/repos/gorilla/securecookie/issues/24","id":120532766,"user":{"login":"keunwoo","id":773433,"avatar_url":"https://avatars.githubusercontent.com/u/773433?v=3","gravatar_id":"","url":"https://api.github.com/users/keunwoo","html_url":"https://github.com/keunwoo","followers_url":"https://api.github.com/users/keunwoo/followers","following_url":"https://api.github.com/users/keunwoo/following{/other_user}","gists_url":"https://api.github.com/users/keunwoo/gists{/gist_id}","starred_url":"https://api.github.com/users/keunwoo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/keunwoo/subscriptions","organizations_url":"https://api.github.com/users/keunwoo/orgs","repos_url":"https://api.github.com/users/keunwoo/repos","events_url":"https://api.github.com/users/keunwoo/events{/privacy}","received_events_url":"https://api.github.com/users/keunwoo/received_events","type":"User","site_admin":false},"created_at":"2015-07-10T21:24:29Z","updated_at":"2015-07-10T21:24:29Z","body":"I honestly don't have a strong preference between an Error interface and the version in the last patchset. I was just posting this to move the discussion forward beyond the stale patch in PR #9. For what it's worth, the vast majority of error types in the Go stdlib are structs, not interfaces; net.Error is the exception, not the rule. OTOH, I think the interface version will indeed be slightly more concise for clients than bitmasking ErrorType, as in the last patchset I uploaded. I'll put together a patchset that implements your suggestion and post it in the next 1-2 business days, so that we can compare them."}}