{"action":"created","issue":{"url":"https://api.github.com/repos/vitaly-t/pg-promise/issues/156","repository_url":"https://api.github.com/repos/vitaly-t/pg-promise","labels_url":"https://api.github.com/repos/vitaly-t/pg-promise/issues/156/labels{/name}","comments_url":"https://api.github.com/repos/vitaly-t/pg-promise/issues/156/comments","events_url":"https://api.github.com/repos/vitaly-t/pg-promise/issues/156/events","html_url":"https://github.com/vitaly-t/pg-promise/issues/156","id":159030846,"number":156,"title":"How to handle errors properly?","user":{"login":"kdex","id":4442505,"avatar_url":"https://avatars.githubusercontent.com/u/4442505?v=3","gravatar_id":"","url":"https://api.github.com/users/kdex","html_url":"https://github.com/kdex","followers_url":"https://api.github.com/users/kdex/followers","following_url":"https://api.github.com/users/kdex/following{/other_user}","gists_url":"https://api.github.com/users/kdex/gists{/gist_id}","starred_url":"https://api.github.com/users/kdex/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kdex/subscriptions","organizations_url":"https://api.github.com/users/kdex/orgs","repos_url":"https://api.github.com/users/kdex/repos","events_url":"https://api.github.com/users/kdex/events{/privacy}","received_events_url":"https://api.github.com/users/kdex/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/vitaly-t/pg-promise/labels/question","name":"question","color":"cc317c"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2016-06-07T21:38:06Z","updated_at":"2016-06-07T22:40:08Z","closed_at":"2016-06-07T22:31:55Z","body":"Is there a \"cleaner\" way to differentiate between errors rather than checking [error.code](https://github.com/kdex/map-game/blob/6fee3651853b6a04aa069616dcb037633a5ac747/src/server/js/db.js#L76) and making [custom mappings](https://github.com/kdex/map-game/blob/6fee3651853b6a04aa069616dcb037633a5ac747/src/server/js/db.js#L9) so the code stays readable? I was wondering if I could just grab these mappings from `pg-promise`, if `node-postgres` exposes something like that.\r\n\r\nAlso, I was wondering how to get more specific errors (for example, consider a `UNIQUE` index which causes an `INSERT` to fail). The end user in front of a registration form would then like to know which field caused the violation, but to the best of my knowledge, all I could rely on would be `error.message`, which I would have to parse in order to output end-user friendly errors. How is that commonly handled?"},"comment":{"url":"https://api.github.com/repos/vitaly-t/pg-promise/issues/comments/224436198","html_url":"https://github.com/vitaly-t/pg-promise/issues/156#issuecomment-224436198","issue_url":"https://api.github.com/repos/vitaly-t/pg-promise/issues/156","id":224436198,"user":{"login":"kdex","id":4442505,"avatar_url":"https://avatars.githubusercontent.com/u/4442505?v=3","gravatar_id":"","url":"https://api.github.com/users/kdex","html_url":"https://github.com/kdex","followers_url":"https://api.github.com/users/kdex/followers","following_url":"https://api.github.com/users/kdex/following{/other_user}","gists_url":"https://api.github.com/users/kdex/gists{/gist_id}","starred_url":"https://api.github.com/users/kdex/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kdex/subscriptions","organizations_url":"https://api.github.com/users/kdex/orgs","repos_url":"https://api.github.com/users/kdex/repos","events_url":"https://api.github.com/users/kdex/events{/privacy}","received_events_url":"https://api.github.com/users/kdex/received_events","type":"User","site_admin":false},"created_at":"2016-06-07T22:40:08Z","updated_at":"2016-06-07T22:40:08Z","body":"Why don't they? Is the error reporting something that PostgreSQL might completely overhaul at some point then? And thank you for the pointer; looks very promising. :+1: "}}
{"actor":{"display_login":"kdex"}}