{"action":"created","comment":{"url":"https://api.github.com/repos/gomods/athens/pulls/comments/204845837","pull_request_review_id":139971564,"id":204845837,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwNDg0NTgzNw==","diff_hunk":"@@ -0,0 +1,153 @@\n+package errors\n+\n+import (\n+\t\"errors\"\n+\t\"net/http\"\n+\n+\t\"github.com/sirupsen/logrus\"\n+)\n+\n+// Kind enums\n+const (\n+\tKindNotFound   = http.StatusNotFound\n+\tKindBadRequest = http.StatusBadRequest\n+\tKindUnexpected = http.StatusInternalServerError\n+)\n+\n+// Error is an Athens system error.\n+// It carries information and behavior\n+// as to what caused this error so that\n+// callers can implement logic around it.\n+type Error struct {\n+\t// Kind categories Athens errors into a smaller\n+\t// subset of errors. This way we can generalize\n+\t// what an error really is: such as \"not found\",\n+\t// \"bad request\", etc. The official categories\n+\t// are HTTP status code but the ones we use are\n+\t// imported into this package.\n+\tKind     int\n+\tOp       Op\n+\tModule   M\n+\tVersion  V\n+\tErr      error\n+\tSeverity logrus.Level\n+}\n+\n+// Error returns the underlying error's\n+// string message. The logger takes care\n+// of filling out the stack levels and\n+// extra information.\n+func (e Error) Error() string {\n+\treturn e.Err.Error()\n+}\n+\n+// Op describes any independent function or\n+// method in Athens. A series of operations\n+// forms a more readable stack trace.\n+type Op string\n+\n+// M represents a module in an error\n+// this is so that we can distinguish\n+// a module from a regular error string or version.\n+type M string\n+\n+// V represents a module version in an error\n+type V string\n+\n+// E is a helper function to construct an Error type\n+// Operation always comes first, module path and version\n+// come second, they are optional. Args must have at least\n+// an error or a string to describe what exactly went wrong.\n+// You can optionally pass a Logrus severity to indicate\n+// the log level of an error based on the context it was constructed in.\n+func E(op Op, args ...interface{}) error {\n+\tif len(args) == 0 {\n+\t\tpanic(\"errors.E called with 0 args\")\n+\t}\n+\te := Error{Op: op}\n+\tfor _, a := range args {\n+\t\tswitch a := a.(type) {\n+\t\tcase error:\n+\t\t\te.Err = a\n+\t\tcase string:\n+\t\t\te.Err = errors.New(a)\n+\t\tcase M:\n+\t\t\te.Module = a\n+\t\tcase V:\n+\t\t\te.Version = a\n+\t\tcase logrus.Level:\n+\t\t\te.Severity = a\n+\t\tcase int:\n+\t\t\te.Kind = a\n+\t\t}\n+\t}\n+\n+\tif e.Err == nil {\n+\t\te.Err = errors.New(\"no error message provided\")\n+\t}\n+\n+\treturn e\n+}\n+\n+// Severity returns the log level of an error\n+// if non exists, then it's an Error level because","path":"pkg/errors/errors.go","position":93,"original_position":93,"commit_id":"bf6bd3a54bab01878e8d7331ce943308854b4725","original_commit_id":"bf6bd3a54bab01878e8d7331ce943308854b4725","user":{"login":"robjloranger","id":13278126,"node_id":"MDQ6VXNlcjEzMjc4MTI2","avatar_url":"https://avatars0.githubusercontent.com/u/13278126?v=4","gravatar_id":"","url":"https://api.github.com/users/robjloranger","html_url":"https://github.com/robjloranger","followers_url":"https://api.github.com/users/robjloranger/followers","following_url":"https://api.github.com/users/robjloranger/following{/other_user}","gists_url":"https://api.github.com/users/robjloranger/gists{/gist_id}","starred_url":"https://api.github.com/users/robjloranger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/robjloranger/subscriptions","organizations_url":"https://api.github.com/users/robjloranger/orgs","repos_url":"https://api.github.com/users/robjloranger/repos","events_url":"https://api.github.com/users/robjloranger/events{/privacy}","received_events_url":"https://api.github.com/users/robjloranger/received_events","type":"User","site_admin":false},"body":"s/if non exists, then it's an Error level because/if none exists, then the level is Error because/","created_at":"2018-07-24T17:34:42Z","updated_at":"2018-07-24T17:55:26Z","html_url":"https://github.com/gomods/athens/pull/320#discussion_r204845837","pull_request_url":"https://api.github.com/repos/gomods/athens/pulls/320","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/gomods/athens/pulls/comments/204845837"},"html":{"href":"https://github.com/gomods/athens/pull/320#discussion_r204845837"},"pull_request":{"href":"https://api.github.com/repos/gomods/athens/pulls/320"}}},"pull_request":{"url":"https://api.github.com/repos/gomods/athens/pulls/320","id":203038023,"node_id":"MDExOlB1bGxSZXF1ZXN0MjAzMDM4MDIz","html_url":"https://github.com/gomods/athens/pull/320","diff_url":"https://github.com/gomods/athens/pull/320.diff","patch_url":"https://github.com/gomods/athens/pull/320.patch","issue_url":"https://api.github.com/repos/gomods/athens/issues/320","number":320,"state":"open","locked":false,"title":"[WIP] Athens: introduce pkg/errors","user":{"login":"marwan-at-work","id":16294261,"node_id":"MDQ6VXNlcjE2Mjk0MjYx","avatar_url":"https://avatars0.githubusercontent.com/u/16294261?v=4","gravatar_id":"","url":"https://api.github.com/users/marwan-at-work","html_url":"https://github.com/marwan-at-work","followers_url":"https://api.github.com/users/marwan-at-work/followers","following_url":"https://api.github.com/users/marwan-at-work/following{/other_user}","gists_url":"https://api.github.com/users/marwan-at-work/gists{/gist_id}","starred_url":"https://api.github.com/users/marwan-at-work/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marwan-at-work/subscriptions","organizations_url":"https://api.github.com/users/marwan-at-work/orgs","repos_url":"https://api.github.com/users/marwan-at-work/repos","events_url":"https://api.github.com/users/marwan-at-work/events{/privacy}","received_events_url":"https://api.github.com/users/marwan-at-work/received_events","type":"User","site_admin":false},"body":"Fixes https://github.com/gomods/athens/issues/275\r\n\r\nTodo: write tests for the errors package and the logger's SystemErr method. \r\n\r\nI'd like to gather some feedback first before writing the tests. \r\n\r\nThings to look out for: \r\n\r\n1. I updated our logger to be \"Athens' Errors Friendly\" using the SystemErr method.\r\n2. I updated download.VersionZipHandler to use pkg/errors, this is so you can check out what it's like to use the package. \r\n3. ~I'm using a copy of cmd/go's semver validation to determine whether a string goes into the Version field. We can use Mastermind's package instead (as suggested by @arschles) but we need to confirm that they both agree to the same semver rules (so far I know cmd/go enforces a \"v\" prefix while Mastermind does not). We can also avoid semver validation by just creating an errors.V type just like errors.Op. Let me know :)~","created_at":"2018-07-22T03:48:46Z","updated_at":"2018-07-24T17:55:26Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5c97f42b891ccfc015bfdd6d8615a4c487834ef9","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/gomods/athens/pulls/320/commits","review_comments_url":"https://api.github.com/repos/gomods/athens/pulls/320/comments","review_comment_url":"https://api.github.com/repos/gomods/athens/pulls/comments{/number}","comments_url":"https://api.github.com/repos/gomods/athens/issues/320/comments","statuses_url":"https://api.github.com/repos/gomods/athens/statuses/bf6bd3a54bab01878e8d7331ce943308854b4725","head":{"label":"marwan-at-work:pkgerr","ref":"pkgerr","sha":"bf6bd3a54bab01878e8d7331ce943308854b4725","user":{"login":"marwan-at-work","id":16294261,"node_id":"MDQ6VXNlcjE2Mjk0MjYx","avatar_url":"https://avatars0.githubusercontent.com/u/16294261?v=4","gravatar_id":"","url":"https://api.github.com/users/marwan-at-work","html_url":"https://github.com/marwan-at-work","followers_url":"https://api.github.com/users/marwan-at-work/followers","following_url":"https://api.github.com/users/marwan-at-work/following{/other_user}","gists_url":"https://api.github.com/users/marwan-at-work/gists{/gist_id}","starred_url":"https://api.github.com/users/marwan-at-work/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marwan-at-work/subscriptions","organizations_url":"https://api.github.com/users/marwan-at-work/orgs","repos_url":"https://api.github.com/users/marwan-at-work/repos","events_url":"https://api.github.com/users/marwan-at-work/events{/privacy}","received_events_url":"https://api.github.com/users/marwan-at-work/received_events","type":"User","site_admin":false},"repo":{"id":140121840,"node_id":"MDEwOlJlcG9zaXRvcnkxNDAxMjE4NDA=","name":"athens","full_name":"marwan-at-work/athens","owner":{"login":"marwan-at-work","id":16294261,"node_id":"MDQ6VXNlcjE2Mjk0MjYx","avatar_url":"https://avatars0.githubusercontent.com/u/16294261?v=4","gravatar_id":"","url":"https://api.github.com/users/marwan-at-work","html_url":"https://github.com/marwan-at-work","followers_url":"https://api.github.com/users/marwan-at-work/followers","following_url":"https://api.github.com/users/marwan-at-work/following{/other_user}","gists_url":"https://api.github.com/users/marwan-at-work/gists{/gist_id}","starred_url":"https://api.github.com/users/marwan-at-work/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marwan-at-work/subscriptions","organizations_url":"https://api.github.com/users/marwan-at-work/orgs","repos_url":"https://api.github.com/users/marwan-at-work/repos","events_url":"https://api.github.com/users/marwan-at-work/events{/privacy}","received_events_url":"https://api.github.com/users/marwan-at-work/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/marwan-at-work/athens","description":"A package registry and proxy server for Go","fork":true,"url":"https://api.github.com/repos/marwan-at-work/athens","forks_url":"https://api.github.com/repos/marwan-at-work/athens/forks","keys_url":"https://api.github.com/repos/marwan-at-work/athens/keys{/key_id}","collaborators_url":"https://api.github.com/repos/marwan-at-work/athens/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/marwan-at-work/athens/teams","hooks_url":"https://api.github.com/repos/marwan-at-work/athens/hooks","issue_events_url":"https://api.github.com/repos/marwan-at-work/athens/issues/events{/number}","events_url":"https://api.github.com/repos/marwan-at-work/athens/events","assignees_url":"https://api.github.com/repos/marwan-at-work/athens/assignees{/user}","branches_url":"https://api.github.com/repos/marwan-at-work/athens/branches{/branch}","tags_url":"https://api.github.com/repos/marwan-at-work/athens/tags","blobs_url":"https://api.github.com/repos/marwan-at-work/athens/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/marwan-at-work/athens/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/marwan-at-work/athens/git/refs{/sha}","trees_url":"https://api.github.com/repos/marwan-at-work/athens/git/trees{/sha}","statuses_url":"https://api.github.com/repos/marwan-at-work/athens/statuses/{sha}","languages_url":"https://api.github.com/repos/marwan-at-work/athens/languages","stargazers_url":"https://api.github.com/repos/marwan-at-work/athens/stargazers","contributors_url":"https://api.github.com/repos/marwan-at-work/athens/contributors","subscribers_url":"https://api.github.com/repos/marwan-at-work/athens/subscribers","subscription_url":"https://api.github.com/repos/marwan-at-work/athens/subscription","commits_url":"https://api.github.com/repos/marwan-at-work/athens/commits{/sha}","git_commits_url":"https://api.github.com/repos/marwan-at-work/athens/git/commits{/sha}","comments_url":"https://api.github.com/repos/marwan-at-work/athens/comments{/number}","issue_comment_url":"https://api.github.com/repos/marwan-at-work/athens/issues/comments{/number}","contents_url":"https://api.github.com/repos/marwan-at-work/athens/contents/{+path}","compare_url":"https://api.github.com/repos/marwan-at-work/athens/compare/{base}...{head}","merges_url":"https://api.github.com/repos/marwan-at-work/athens/merges","archive_url":"https://api.github.com/repos/marwan-at-work/athens/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/marwan-at-work/athens/downloads","issues_url":"https://api.github.com/repos/marwan-at-work/athens/issues{/number}","pulls_url":"https://api.github.com/repos/marwan-at-work/athens/pulls{/number}","milestones_url":"https://api.github.com/repos/marwan-at-work/athens/milestones{/number}","notifications_url":"https://api.github.com/repos/marwan-at-work/athens/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/marwan-at-work/athens/labels{/name}","releases_url":"https://api.github.com/repos/marwan-at-work/athens/releases{/id}","deployments_url":"https://api.github.com/repos/marwan-at-work/athens/deployments","created_at":"2018-07-07T22:50:55Z","updated_at":"2018-07-07T22:50:58Z","pushed_at":"2018-07-24T15:03:34Z","git_url":"git://github.com/marwan-at-work/athens.git","ssh_url":"git@github.com:marwan-at-work/athens.git","clone_url":"https://github.com/marwan-at-work/athens.git","svn_url":"https://github.com/marwan-at-work/athens","homepage":"","size":60792,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"gomods:master","ref":"master","sha":"484b020556d5b8aaa554f0241caa03dc08cdffa0","user":{"login":"gomods","id":36861827,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM2ODYxODI3","avatar_url":"https://avatars3.githubusercontent.com/u/36861827?v=4","gravatar_id":"","url":"https://api.github.com/users/gomods","html_url":"https://github.com/gomods","followers_url":"https://api.github.com/users/gomods/followers","following_url":"https://api.github.com/users/gomods/following{/other_user}","gists_url":"https://api.github.com/users/gomods/gists{/gist_id}","starred_url":"https://api.github.com/users/gomods/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gomods/subscriptions","organizations_url":"https://api.github.com/users/gomods/orgs","repos_url":"https://api.github.com/users/gomods/repos","events_url":"https://api.github.com/users/gomods/events{/privacy}","received_events_url":"https://api.github.com/users/gomods/received_events","type":"Organization","site_admin":false},"repo":{"id":122872932,"node_id":"MDEwOlJlcG9zaXRvcnkxMjI4NzI5MzI=","name":"athens","full_name":"gomods/athens","owner":{"login":"gomods","id":36861827,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM2ODYxODI3","avatar_url":"https://avatars3.githubusercontent.com/u/36861827?v=4","gravatar_id":"","url":"https://api.github.com/users/gomods","html_url":"https://github.com/gomods","followers_url":"https://api.github.com/users/gomods/followers","following_url":"https://api.github.com/users/gomods/following{/other_user}","gists_url":"https://api.github.com/users/gomods/gists{/gist_id}","starred_url":"https://api.github.com/users/gomods/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gomods/subscriptions","organizations_url":"https://api.github.com/users/gomods/orgs","repos_url":"https://api.github.com/users/gomods/repos","events_url":"https://api.github.com/users/gomods/events{/privacy}","received_events_url":"https://api.github.com/users/gomods/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/gomods/athens","description":"A package registry and proxy server for Go","fork":false,"url":"https://api.github.com/repos/gomods/athens","forks_url":"https://api.github.com/repos/gomods/athens/forks","keys_url":"https://api.github.com/repos/gomods/athens/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gomods/athens/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gomods/athens/teams","hooks_url":"https://api.github.com/repos/gomods/athens/hooks","issue_events_url":"https://api.github.com/repos/gomods/athens/issues/events{/number}","events_url":"https://api.github.com/repos/gomods/athens/events","assignees_url":"https://api.github.com/repos/gomods/athens/assignees{/user}","branches_url":"https://api.github.com/repos/gomods/athens/branches{/branch}","tags_url":"https://api.github.com/repos/gomods/athens/tags","blobs_url":"https://api.github.com/repos/gomods/athens/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gomods/athens/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gomods/athens/git/refs{/sha}","trees_url":"https://api.github.com/repos/gomods/athens/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gomods/athens/statuses/{sha}","languages_url":"https://api.github.com/repos/gomods/athens/languages","stargazers_url":"https://api.github.com/repos/gomods/athens/stargazers","contributors_url":"https://api.github.com/repos/gomods/athens/contributors","subscribers_url":"https://api.github.com/repos/gomods/athens/subscribers","subscription_url":"https://api.github.com/repos/gomods/athens/subscription","commits_url":"https://api.github.com/repos/gomods/athens/commits{/sha}","git_commits_url":"https://api.github.com/repos/gomods/athens/git/commits{/sha}","comments_url":"https://api.github.com/repos/gomods/athens/comments{/number}","issue_comment_url":"https://api.github.com/repos/gomods/athens/issues/comments{/number}","contents_url":"https://api.github.com/repos/gomods/athens/contents/{+path}","compare_url":"https://api.github.com/repos/gomods/athens/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gomods/athens/merges","archive_url":"https://api.github.com/repos/gomods/athens/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gomods/athens/downloads","issues_url":"https://api.github.com/repos/gomods/athens/issues{/number}","pulls_url":"https://api.github.com/repos/gomods/athens/pulls{/number}","milestones_url":"https://api.github.com/repos/gomods/athens/milestones{/number}","notifications_url":"https://api.github.com/repos/gomods/athens/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gomods/athens/labels{/name}","releases_url":"https://api.github.com/repos/gomods/athens/releases{/id}","deployments_url":"https://api.github.com/repos/gomods/athens/deployments","created_at":"2018-02-25T20:19:41Z","updated_at":"2018-07-24T14:33:06Z","pushed_at":"2018-07-24T15:03:35Z","git_url":"git://github.com/gomods/athens.git","ssh_url":"git@github.com:gomods/athens.git","clone_url":"https://github.com/gomods/athens.git","svn_url":"https://github.com/gomods/athens","homepage":"","size":44428,"stargazers_count":382,"watchers_count":382,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":31,"mirror_url":null,"archived":false,"open_issues_count":77,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":31,"open_issues":77,"watchers":382,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/gomods/athens/pulls/320"},"html":{"href":"https://github.com/gomods/athens/pull/320"},"issue":{"href":"https://api.github.com/repos/gomods/athens/issues/320"},"comments":{"href":"https://api.github.com/repos/gomods/athens/issues/320/comments"},"review_comments":{"href":"https://api.github.com/repos/gomods/athens/pulls/320/comments"},"review_comment":{"href":"https://api.github.com/repos/gomods/athens/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/gomods/athens/pulls/320/commits"},"statuses":{"href":"https://api.github.com/repos/gomods/athens/statuses/bf6bd3a54bab01878e8d7331ce943308854b4725"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"robjloranger"}}