{"action":"opened","issue":{"url":"https://api.github.com/repos/brianc/node-postgres/issues/1793","repository_url":"https://api.github.com/repos/brianc/node-postgres","labels_url":"https://api.github.com/repos/brianc/node-postgres/issues/1793/labels{/name}","comments_url":"https://api.github.com/repos/brianc/node-postgres/issues/1793/comments","events_url":"https://api.github.com/repos/brianc/node-postgres/issues/1793/events","html_url":"https://github.com/brianc/node-postgres/issues/1793","id":393921635,"node_id":"MDU6SXNzdWUzOTM5MjE2MzU=","number":1793,"title":"Connection error messages stacks only contain functions in node-postgres","user":{"login":"jonsemail4","id":25064885,"node_id":"MDQ6VXNlcjI1MDY0ODg1","avatar_url":"https://avatars3.githubusercontent.com/u/25064885?v=4","gravatar_id":"","url":"https://api.github.com/users/jonsemail4","html_url":"https://github.com/jonsemail4","followers_url":"https://api.github.com/users/jonsemail4/followers","following_url":"https://api.github.com/users/jonsemail4/following{/other_user}","gists_url":"https://api.github.com/users/jonsemail4/gists{/gist_id}","starred_url":"https://api.github.com/users/jonsemail4/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jonsemail4/subscriptions","organizations_url":"https://api.github.com/users/jonsemail4/orgs","repos_url":"https://api.github.com/users/jonsemail4/repos","events_url":"https://api.github.com/users/jonsemail4/events{/privacy}","received_events_url":"https://api.github.com/users/jonsemail4/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-12-24T19:03:50Z","updated_at":"2018-12-24T19:03:50Z","closed_at":null,"author_association":"NONE","body":"For example\r\n```javascript\r\nconst db = new Pool({\r\n  connectionString: 'postgresql://...@localhost:5432/...'\r\n});\r\ndb.query('SELECT, * FROM test1');\r\n```\r\ngenerates the rather unhelpful stack\r\n```\r\n{ error: syntax error at or near \",\"\r\n    at Connection.parseE (.../node_modules/pg/lib/connection.js:554:11)\r\n    at Connection.parseMessage (.../node_modules/pg/lib/connection.js:379:19)\r\n    at Socket.<anonymous> (.../node_modules/pg/lib/connection.js:119:22)\r\n    at Socket.emit (events.js:182:13)\r\n    at addChunk (_stream_readable.js:283:12)\r\n    at readableAddChunk (_stream_readable.js:264:11)\r\n    at Socket.Readable.push (_stream_readable.js:219:10)\r\n    at TCP.onStreamRead [as onread] (internal/stream_base_commons.js:94:17)\r\n  [stack]:\r\n   'error: syntax error at or near \",\"\\n    at Connection.parseE (.../node_modules/pg/lib/connection.js:554:11)\\n    at Connection.parseMessage (.../node_modules/pg/lib/connection.js:379:19)\\n    at Socket.<anonymous> (.../node_modules/pg/lib/connection.js:119:22)\\n    at Socket.emit (events.js:182:13)\\n    at addChunk (_stream_readable.js:283:12)\\n    at readableAddChunk (_stream_readable.js:264:11)\\n    at Socket.Readable.push (_stream_readable.js:219:10)\\n    at TCP.onStreamRead [as onread] (internal/stream_base_commons.js:94:17)',\r\n  [message]: 'syntax error at or near \",\"',\r\n  ...}\r\n```\r\nNote, in particular, the absense of line numbers in *my* code, only in the `node-postgres` code.\r\n\r\nIt's easy enough to fix this outside of the package. I can just add something like\r\n```javascript\r\nfunction withError(queryFunc) {\r\n  return async function(query) {\r\n    try {\r\n      const res = await queryFunc.call(this, query);\r\n    } catch (e) {\r\n      throw new VError(e, 'pg error');\r\n    }\r\n  };\r\n}\r\ndb.query = withError(db.query);\r\n```\r\nand then we get the error info.\r\n\r\nI'm guessing this has something to do with the error being thrown by a listener or something (?)?"}}
{"actor":{"display_login":"jonsemail4"}}