{"action":"created","issue":{"url":"https://api.github.com/repos/isomorphic-git/isomorphic-git/issues/287","repository_url":"https://api.github.com/repos/isomorphic-git/isomorphic-git","labels_url":"https://api.github.com/repos/isomorphic-git/isomorphic-git/issues/287/labels{/name}","comments_url":"https://api.github.com/repos/isomorphic-git/isomorphic-git/issues/287/comments","events_url":"https://api.github.com/repos/isomorphic-git/isomorphic-git/issues/287/events","html_url":"https://github.com/isomorphic-git/isomorphic-git/pull/287","id":333147387,"node_id":"MDExOlB1bGxSZXF1ZXN0MTk1NDMyMjg2","number":287,"title":"(WIP) formalize Error Codes","user":{"login":"wmhilton","id":587740,"node_id":"MDQ6VXNlcjU4Nzc0MA==","avatar_url":"https://avatars2.githubusercontent.com/u/587740?v=4","gravatar_id":"","url":"https://api.github.com/users/wmhilton","html_url":"https://github.com/wmhilton","followers_url":"https://api.github.com/users/wmhilton/followers","following_url":"https://api.github.com/users/wmhilton/following{/other_user}","gists_url":"https://api.github.com/users/wmhilton/gists{/gist_id}","starred_url":"https://api.github.com/users/wmhilton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wmhilton/subscriptions","organizations_url":"https://api.github.com/users/wmhilton/orgs","repos_url":"https://api.github.com/users/wmhilton/repos","events_url":"https://api.github.com/users/wmhilton/events{/privacy}","received_events_url":"https://api.github.com/users/wmhilton/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2018-06-18T06:31:22Z","updated_at":"2018-06-20T16:56:51Z","closed_at":null,"author_association":"MEMBER","pull_request":{"url":"https://api.github.com/repos/isomorphic-git/isomorphic-git/pulls/287","html_url":"https://github.com/isomorphic-git/isomorphic-git/pull/287","diff_url":"https://github.com/isomorphic-git/isomorphic-git/pull/287.diff","patch_url":"https://github.com/isomorphic-git/isomorphic-git/pull/287.patch"},"body":"a variation on #217 with a more traditional approach\r\n\r\n* * *\r\n\r\nThis adds a new model, GitError. A GitError extends the base Error class in JavaScript, with some new properties and changes some existing properties:\r\n- a `caller` string (see #262)\r\n- a `code` string\r\n- a `data` object\r\n- a `message` string; however that string is now declared in a central location, templated with `{ placeholders }` filled in by `data`, and translated based on locale. (Hopefully volunteers will provide translations in other languages!)\r\n- a `toJSON` method; returns { code, data, caller, message }\r\n- a `toString` method that shows the message and stack trace; however it now prints the error code instead of just \"Error:\" at the beginning.\r\n\r\n# Example\r\n```js\r\nimport { E, GitError } from '../models';\r\ntry {\r\n  throw new GitError(E.FileReadError, { filepath: 'foobar.txt' })\r\n} catch (err) {\r\n  if (err.code === E.FileReadError) {\r\n    console.log(err.toString())    // FileReadError: Could not read file \"foobar.txt\"\r\n    console.log(err.data.filepath) // foobar.txt\r\n    console.log(err.toJSON())      /* {\r\n                                      caller: undefined,\r\n                                      code: \"FileReadError\",\r\n                                      data: { filepath: \"foobar.txt\" },\r\n                                      message: 'Could not read file \"foobar.txt\"' \r\n                                    } */\r\n  } else {\r\n    console.log('unhandled error', err)\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/isomorphic-git/isomorphic-git/issues/comments/398822231","html_url":"https://github.com/isomorphic-git/isomorphic-git/pull/287#issuecomment-398822231","issue_url":"https://api.github.com/repos/isomorphic-git/isomorphic-git/issues/287","id":398822231,"node_id":"MDEyOklzc3VlQ29tbWVudDM5ODgyMjIzMQ==","user":{"login":"wmhilton","id":587740,"node_id":"MDQ6VXNlcjU4Nzc0MA==","avatar_url":"https://avatars2.githubusercontent.com/u/587740?v=4","gravatar_id":"","url":"https://api.github.com/users/wmhilton","html_url":"https://github.com/wmhilton","followers_url":"https://api.github.com/users/wmhilton/followers","following_url":"https://api.github.com/users/wmhilton/following{/other_user}","gists_url":"https://api.github.com/users/wmhilton/gists{/gist_id}","starred_url":"https://api.github.com/users/wmhilton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wmhilton/subscriptions","organizations_url":"https://api.github.com/users/wmhilton/orgs","repos_url":"https://api.github.com/users/wmhilton/repos","events_url":"https://api.github.com/users/wmhilton/events{/privacy}","received_events_url":"https://api.github.com/users/wmhilton/received_events","type":"User","site_admin":false},"created_at":"2018-06-20T16:56:51Z","updated_at":"2018-06-20T16:56:51Z","author_association":"MEMBER","body":"This probably isn't a good one to start with, because we'd likely have merge conflicts if we both tried to write to this branch. Maybe this weekend I'll do a livecoding session and make an official getting started tutorial!"}}
{"actor":{"display_login":"wmhilton"}}