{"action":"created","comment":{"url":"https://api.github.com/repos/json-api/json-api/pulls/comments/37701991","id":37701991,"diff_hunk":"@@ -162,3 +162,242 @@ Content-Type: application/vnd.api+json\n   }\n }\n ```\n+\n+## Error Objects\n+\n+Examples of how [error objects](http://jsonapi.org/format/#error-objects) work.\n+\n+### A Basic Error Object\n+\n+In the response below, the server is indicating that it encountered an error\n+while creating/updating the resource, and that this error was caused\n+by an invalid `\"first-name\"` attribute:\n+\n+```http\n+HTTP/1.1 422 Unprocessable Entity\n+Content-Type: application/vnd.api+json\n+\n+{\n+  \"errors\": [\n+    {\n+      \"status\": \"422\",\n+      \"source\": { \"pointer\": \"/data/attributes/first-name\" },\n+      \"title\":  \"Invalid Attribute\",\n+      \"detail\": \"First name must contain at least three characters.\"\n+    }\n+  ]\n+}\n+```\n+\n+Every member in an error object is optional, but all help the client\n+by providing extra details.\n+\n+The `source` member is used to [indicate](https://tools.ietf.org/html/rfc6901)\n+which part of the request document caused the error.\n+\n+The `title` and `detail` members are similar, but `detail` is specific\n+to this occurrence of the problem, whereas `title` is more generic.\n+\n+The `status` member represents the HTTP status code associated with the problem.\n+It's very helpful when multiple errors are returned at once (see below), as the\n+HTTP response itself can only have one status code. However, it can also be\n+useful for single errors, to save clients the trouble of consulting the HTTP\n+headers, or for using JSON API over non-HTTP protocols, which may be officially\n+supported in the near future.\n+\n+### Multiple Errors\n+\n+When multiple errors occur in response to a single request, the server\n+can simply add each error to the `errors` array:\n+\n+```http\n+HTTP/1.1 400 Bad Request\n+Content-Type: application/vnd.api+json\n+\n+{\n+  \"errors\": [\n+    {\n+      \"status\": \"403\",\n+      \"source\": { \"pointer\": \"data/attributes/secret-powers\" },\n+      \"detail\": \"Editing secret powers is not authorized on Sundays.\"\n+    },\n+    {\n+      \"status\": \"422\",\n+      \"source\": { \"pointer\": \"data/attributes/volume\" },\n+      \"detail\": \"Volume does not, in fact, go to 11.\"\n+    },\n+    {\n+      \"status\": \"500\",\n+      \"source\": { \"pointer\": \"data/attributes/reputation\" },","path":"examples/index.md","position":70,"original_position":70,"commit_id":"2cc93bdf029b1d8fc8b45cbb104ca542f48fd5a7","original_commit_id":"2cc93bdf029b1d8fc8b45cbb104ca542f48fd5a7","user":{"login":"ethanresnick","id":471894,"avatar_url":"https://avatars.githubusercontent.com/u/471894?v=3","gravatar_id":"","url":"https://api.github.com/users/ethanresnick","html_url":"https://github.com/ethanresnick","followers_url":"https://api.github.com/users/ethanresnick/followers","following_url":"https://api.github.com/users/ethanresnick/following{/other_user}","gists_url":"https://api.github.com/users/ethanresnick/gists{/gist_id}","starred_url":"https://api.github.com/users/ethanresnick/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ethanresnick/subscriptions","organizations_url":"https://api.github.com/users/ethanresnick/orgs","repos_url":"https://api.github.com/users/ethanresnick/repos","events_url":"https://api.github.com/users/ethanresnick/events{/privacy}","received_events_url":"https://api.github.com/users/ethanresnick/received_events","type":"User","site_admin":false},"body":"Ditto","created_at":"2015-08-23T02:21:07Z","updated_at":"2015-08-23T02:21:07Z","html_url":"https://github.com/json-api/json-api/pull/828#discussion_r37701991","pull_request_url":"https://api.github.com/repos/json-api/json-api/pulls/828","_links":{"self":{"href":"https://api.github.com/repos/json-api/json-api/pulls/comments/37701991"},"html":{"href":"https://github.com/json-api/json-api/pull/828#discussion_r37701991"},"pull_request":{"href":"https://api.github.com/repos/json-api/json-api/pulls/828"}}},"pull_request":{"url":"https://api.github.com/repos/json-api/json-api/pulls/828","id":41715997,"html_url":"https://github.com/json-api/json-api/pull/828","diff_url":"https://github.com/json-api/json-api/pull/828.diff","patch_url":"https://github.com/json-api/json-api/pull/828.patch","issue_url":"https://api.github.com/repos/json-api/json-api/issues/828","number":828,"state":"open","locked":false,"title":"Example Error Objects","user":{"login":"bf4","id":142914,"avatar_url":"https://avatars.githubusercontent.com/u/142914?v=3","gravatar_id":"","url":"https://api.github.com/users/bf4","html_url":"https://github.com/bf4","followers_url":"https://api.github.com/users/bf4/followers","following_url":"https://api.github.com/users/bf4/following{/other_user}","gists_url":"https://api.github.com/users/bf4/gists{/gist_id}","starred_url":"https://api.github.com/users/bf4/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bf4/subscriptions","organizations_url":"https://api.github.com/users/bf4/orgs","repos_url":"https://api.github.com/users/bf4/repos","events_url":"https://api.github.com/users/bf4/events{/privacy}","received_events_url":"https://api.github.com/users/bf4/received_events","type":"User","site_admin":false},"body":"Per discussion with @dgeb in https://github.com/rails-api/active_model_serializers/pull/1004\n\n> Although it is still compliant to represent multiple validation errors in the same error object,\n> it's not ideal. I would recommend creating a unique error object per validation error,\n> so that fields such as code and title can be used consistently and expressively across errors.\n> For instance, one code might indicate that a field is too short, and another might indicate\n> that invalid characters were used. If you try to combine these errors into a single code,\n> then it will probably end up being something more generic with less meaning, such as \"invalid value\".\n\nReferences:\n- http://jsonapi.org/format/#error-object\n- Discussion in PRs\n  - https://github.com/json-api/json-api/pull/237 [specifically](https://github.com/json-api/json-api/commit/6901143531c14f41e95818455fe36228cebf6625) and https://github.com/json-api/json-api/pull/638\n  - https://github.com/json-api/json-api/pull/234\n  - https://github.com/json-api/json-api/issues/7\n  - https://github.com/json-api/json-api/pull/208\n- Usage in Ember\n  - http://emberjs.com/blog/2015/06/18/ember-data-1-13-released.html#toc_using-json-api-error-object-format\n  - ember-data\n    - [lib/adapters/errors.js](https://github.com/emberjs/data/blob/d842890357840700f0ee17f152415be0cba16030/packages/ember-data/lib/adapters/errors.js#L114-L132)\n    - [lib/adapters/rest-adapter.js](https://github.com/emberjs/data/blob/3930e457f36a0bbdde0155c1b98ebe976e607358/packages/ember-data/lib/adapters/rest-adapter.js#L913-L925)\n    - [lib/serializers/json-serializer.js](https://github.com/emberjs/data/blob/944f7e4b537cdc7cd2a80718d0447453c01de2db/packages/ember-data/lib/serializers/json-serializer.js#L1225-L1276)\n    - [adapter-errors-test.js](https://github.com/emberjs/data/blob/21ebe9b61b33acd910c0d485e17926c89c51d9f6/packages/ember-data/tests/unit/adapter-errors-test.js#L32-L48)\n    - [json-serializer-test.js](https://github.com/emberjs/data/blob/90a0011c8e5e1c41d1667c96a38c4a5e4a9c1e64/packages/ember-data/tests/integration/serializers/json-serializer-test.js#L566-L622)","created_at":"2015-08-05T19:24:25Z","updated_at":"2015-08-23T02:21:07Z","closed_at":null,"merged_at":null,"merge_commit_sha":"50d85c81bd93698c5b29ebf759355fdf7240327a","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/json-api/json-api/pulls/828/commits","review_comments_url":"https://api.github.com/repos/json-api/json-api/pulls/828/comments","review_comment_url":"https://api.github.com/repos/json-api/json-api/pulls/comments{/number}","comments_url":"https://api.github.com/repos/json-api/json-api/issues/828/comments","statuses_url":"https://api.github.com/repos/json-api/json-api/statuses/2cc93bdf029b1d8fc8b45cbb104ca542f48fd5a7","head":{"label":"bf4:errors_example","ref":"errors_example","sha":"2cc93bdf029b1d8fc8b45cbb104ca542f48fd5a7","user":{"login":"bf4","id":142914,"avatar_url":"https://avatars.githubusercontent.com/u/142914?v=3","gravatar_id":"","url":"https://api.github.com/users/bf4","html_url":"https://github.com/bf4","followers_url":"https://api.github.com/users/bf4/followers","following_url":"https://api.github.com/users/bf4/following{/other_user}","gists_url":"https://api.github.com/users/bf4/gists{/gist_id}","starred_url":"https://api.github.com/users/bf4/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bf4/subscriptions","organizations_url":"https://api.github.com/users/bf4/orgs","repos_url":"https://api.github.com/users/bf4/repos","events_url":"https://api.github.com/users/bf4/events{/privacy}","received_events_url":"https://api.github.com/users/bf4/received_events","type":"User","site_admin":false},"repo":{"id":40263633,"name":"json-api","full_name":"bf4/json-api","owner":{"login":"bf4","id":142914,"avatar_url":"https://avatars.githubusercontent.com/u/142914?v=3","gravatar_id":"","url":"https://api.github.com/users/bf4","html_url":"https://github.com/bf4","followers_url":"https://api.github.com/users/bf4/followers","following_url":"https://api.github.com/users/bf4/following{/other_user}","gists_url":"https://api.github.com/users/bf4/gists{/gist_id}","starred_url":"https://api.github.com/users/bf4/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bf4/subscriptions","organizations_url":"https://api.github.com/users/bf4/orgs","repos_url":"https://api.github.com/users/bf4/repos","events_url":"https://api.github.com/users/bf4/events{/privacy}","received_events_url":"https://api.github.com/users/bf4/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/bf4/json-api","description":"A specification for building JSON APIs","fork":true,"url":"https://api.github.com/repos/bf4/json-api","forks_url":"https://api.github.com/repos/bf4/json-api/forks","keys_url":"https://api.github.com/repos/bf4/json-api/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bf4/json-api/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bf4/json-api/teams","hooks_url":"https://api.github.com/repos/bf4/json-api/hooks","issue_events_url":"https://api.github.com/repos/bf4/json-api/issues/events{/number}","events_url":"https://api.github.com/repos/bf4/json-api/events","assignees_url":"https://api.github.com/repos/bf4/json-api/assignees{/user}","branches_url":"https://api.github.com/repos/bf4/json-api/branches{/branch}","tags_url":"https://api.github.com/repos/bf4/json-api/tags","blobs_url":"https://api.github.com/repos/bf4/json-api/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bf4/json-api/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bf4/json-api/git/refs{/sha}","trees_url":"https://api.github.com/repos/bf4/json-api/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bf4/json-api/statuses/{sha}","languages_url":"https://api.github.com/repos/bf4/json-api/languages","stargazers_url":"https://api.github.com/repos/bf4/json-api/stargazers","contributors_url":"https://api.github.com/repos/bf4/json-api/contributors","subscribers_url":"https://api.github.com/repos/bf4/json-api/subscribers","subscription_url":"https://api.github.com/repos/bf4/json-api/subscription","commits_url":"https://api.github.com/repos/bf4/json-api/commits{/sha}","git_commits_url":"https://api.github.com/repos/bf4/json-api/git/commits{/sha}","comments_url":"https://api.github.com/repos/bf4/json-api/comments{/number}","issue_comment_url":"https://api.github.com/repos/bf4/json-api/issues/comments{/number}","contents_url":"https://api.github.com/repos/bf4/json-api/contents/{+path}","compare_url":"https://api.github.com/repos/bf4/json-api/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bf4/json-api/merges","archive_url":"https://api.github.com/repos/bf4/json-api/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bf4/json-api/downloads","issues_url":"https://api.github.com/repos/bf4/json-api/issues{/number}","pulls_url":"https://api.github.com/repos/bf4/json-api/pulls{/number}","milestones_url":"https://api.github.com/repos/bf4/json-api/milestones{/number}","notifications_url":"https://api.github.com/repos/bf4/json-api/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bf4/json-api/labels{/name}","releases_url":"https://api.github.com/repos/bf4/json-api/releases{/id}","created_at":"2015-08-05T19:01:03Z","updated_at":"2015-08-21T07:10:08Z","pushed_at":"2015-08-23T02:02:26Z","git_url":"git://github.com/bf4/json-api.git","ssh_url":"git@github.com:bf4/json-api.git","clone_url":"https://github.com/bf4/json-api.git","svn_url":"https://github.com/bf4/json-api","homepage":"http://jsonapi.org","size":1246,"stargazers_count":1,"watchers_count":1,"language":"CSS","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":1,"mirror_url":null,"open_issues_count":0,"forks":1,"open_issues":0,"watchers":1,"default_branch":"gh-pages"}},"base":{"label":"json-api:gh-pages","ref":"gh-pages","sha":"6a410c0068dcce1813ac4c0b5a875adbef759729","user":{"login":"json-api","id":4341694,"avatar_url":"https://avatars.githubusercontent.com/u/4341694?v=3","gravatar_id":"","url":"https://api.github.com/users/json-api","html_url":"https://github.com/json-api","followers_url":"https://api.github.com/users/json-api/followers","following_url":"https://api.github.com/users/json-api/following{/other_user}","gists_url":"https://api.github.com/users/json-api/gists{/gist_id}","starred_url":"https://api.github.com/users/json-api/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/json-api/subscriptions","organizations_url":"https://api.github.com/users/json-api/orgs","repos_url":"https://api.github.com/users/json-api/repos","events_url":"https://api.github.com/users/json-api/events{/privacy}","received_events_url":"https://api.github.com/users/json-api/received_events","type":"Organization","site_admin":false},"repo":{"id":9859154,"name":"json-api","full_name":"json-api/json-api","owner":{"login":"json-api","id":4341694,"avatar_url":"https://avatars.githubusercontent.com/u/4341694?v=3","gravatar_id":"","url":"https://api.github.com/users/json-api","html_url":"https://github.com/json-api","followers_url":"https://api.github.com/users/json-api/followers","following_url":"https://api.github.com/users/json-api/following{/other_user}","gists_url":"https://api.github.com/users/json-api/gists{/gist_id}","starred_url":"https://api.github.com/users/json-api/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/json-api/subscriptions","organizations_url":"https://api.github.com/users/json-api/orgs","repos_url":"https://api.github.com/users/json-api/repos","events_url":"https://api.github.com/users/json-api/events{/privacy}","received_events_url":"https://api.github.com/users/json-api/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/json-api/json-api","description":"A specification for building JSON APIs","fork":false,"url":"https://api.github.com/repos/json-api/json-api","forks_url":"https://api.github.com/repos/json-api/json-api/forks","keys_url":"https://api.github.com/repos/json-api/json-api/keys{/key_id}","collaborators_url":"https://api.github.com/repos/json-api/json-api/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/json-api/json-api/teams","hooks_url":"https://api.github.com/repos/json-api/json-api/hooks","issue_events_url":"https://api.github.com/repos/json-api/json-api/issues/events{/number}","events_url":"https://api.github.com/repos/json-api/json-api/events","assignees_url":"https://api.github.com/repos/json-api/json-api/assignees{/user}","branches_url":"https://api.github.com/repos/json-api/json-api/branches{/branch}","tags_url":"https://api.github.com/repos/json-api/json-api/tags","blobs_url":"https://api.github.com/repos/json-api/json-api/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/json-api/json-api/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/json-api/json-api/git/refs{/sha}","trees_url":"https://api.github.com/repos/json-api/json-api/git/trees{/sha}","statuses_url":"https://api.github.com/repos/json-api/json-api/statuses/{sha}","languages_url":"https://api.github.com/repos/json-api/json-api/languages","stargazers_url":"https://api.github.com/repos/json-api/json-api/stargazers","contributors_url":"https://api.github.com/repos/json-api/json-api/contributors","subscribers_url":"https://api.github.com/repos/json-api/json-api/subscribers","subscription_url":"https://api.github.com/repos/json-api/json-api/subscription","commits_url":"https://api.github.com/repos/json-api/json-api/commits{/sha}","git_commits_url":"https://api.github.com/repos/json-api/json-api/git/commits{/sha}","comments_url":"https://api.github.com/repos/json-api/json-api/comments{/number}","issue_comment_url":"https://api.github.com/repos/json-api/json-api/issues/comments{/number}","contents_url":"https://api.github.com/repos/json-api/json-api/contents/{+path}","compare_url":"https://api.github.com/repos/json-api/json-api/compare/{base}...{head}","merges_url":"https://api.github.com/repos/json-api/json-api/merges","archive_url":"https://api.github.com/repos/json-api/json-api/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/json-api/json-api/downloads","issues_url":"https://api.github.com/repos/json-api/json-api/issues{/number}","pulls_url":"https://api.github.com/repos/json-api/json-api/pulls{/number}","milestones_url":"https://api.github.com/repos/json-api/json-api/milestones{/number}","notifications_url":"https://api.github.com/repos/json-api/json-api/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/json-api/json-api/labels{/name}","releases_url":"https://api.github.com/repos/json-api/json-api/releases{/id}","created_at":"2013-05-04T19:29:30Z","updated_at":"2015-08-22T20:54:09Z","pushed_at":"2015-08-23T02:02:27Z","git_url":"git://github.com/json-api/json-api.git","ssh_url":"git@github.com:json-api/json-api.git","clone_url":"https://github.com/json-api/json-api.git","svn_url":"https://github.com/json-api/json-api","homepage":"http://jsonapi.org","size":4700,"stargazers_count":2776,"watchers_count":2776,"language":"CSS","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":332,"mirror_url":null,"open_issues_count":54,"forks":332,"open_issues":54,"watchers":2776,"default_branch":"gh-pages"}},"_links":{"self":{"href":"https://api.github.com/repos/json-api/json-api/pulls/828"},"html":{"href":"https://github.com/json-api/json-api/pull/828"},"issue":{"href":"https://api.github.com/repos/json-api/json-api/issues/828"},"comments":{"href":"https://api.github.com/repos/json-api/json-api/issues/828/comments"},"review_comments":{"href":"https://api.github.com/repos/json-api/json-api/pulls/828/comments"},"review_comment":{"href":"https://api.github.com/repos/json-api/json-api/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/json-api/json-api/pulls/828/commits"},"statuses":{"href":"https://api.github.com/repos/json-api/json-api/statuses/2cc93bdf029b1d8fc8b45cbb104ca542f48fd5a7"}}}}