diff --git a/lib/data-managers/postgres-manager.js b/lib/data-managers/postgres-manager.js index 8ffe0f3..97cd7c7 100644 --- a/lib/data-managers/postgres-manager.js +++ b/lib/data-managers/postgres-manager.js @@ -18,6 +18,33 @@ export default class PostgresManager extends DataManager { execute(database, query, onQueryToken) { return new Promise((resolve, reject) => { var url = database !== '' ? this.dbConfig.getUrlWithDb(database) : this.dbConfig.getUrl(); + + var errorfunc = function (err, client) { + var notification = { + buttons: [ + { + className: "btn-details", + onDidClick: function() { + var editor = atom.workspace.getActiveTextEditor(); + editor.setCursorBufferPosition(0,0); + editor.moveRight(err.position); + }, + text: "=>" + } + ], + dismissable: true, + detail: JSON.stringify(err) + }; + if (err.severity == 'INFO' || err.severity == 'NOTICE') { + atom.notifications.addInfo(err.message, notification); + } else if (err.severity == 'WARNING') { + atom.notifications.addWarning(err.message, notification); + } else { + atom.notifications.addError(err.message, notification); + } + console.log(err.message, JSON.stringify(err)) + }; + pg.connect(url, (err, client, done) => { if (err) { // call `done()` to release the client back to the pool @@ -25,6 +52,8 @@ export default class PostgresManager extends DataManager { reject(this.buildErrorMessage(err)); } else { + client.on('notice', errorfunc); + client.on('error', errorfunc); var pgQuery = client.query({text: query, rowMode: 'array', multiResult: true}, (err, results) => { if (err) { done(); @@ -32,6 +61,7 @@ export default class PostgresManager extends DataManager { } else { done(); + errorfunc(err, client); resolve(this.translateResults(results)); } });