Skip to content

Commit

Permalink
improved string conversion.
Browse files Browse the repository at this point in the history
  • Loading branch information
vitaly-t committed Apr 8, 2016
1 parent 8b920cf commit cf289f7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
7 changes: 5 additions & 2 deletions lib/errors.js
Expand Up @@ -136,8 +136,7 @@ QueryResultError.prototype = Object.create(Error.prototype, {
}
});

// well-formatted output when passed into console.log();
QueryResultError.prototype.inspect = function () {
QueryResultError.prototype.toString = function () {
var lines = [
"QueryResultError {",
" code: queryResultErrorCode." + errorMessages[this.code].name,
Expand All @@ -152,6 +151,10 @@ QueryResultError.prototype.inspect = function () {
return lines.join(EOL);
};

QueryResultError.prototype.inspect = function () {
return this.toString();
};

module.exports = {
QueryResultError: QueryResultError,
queryResultErrorCode: queryResultErrorCode
Expand Down
8 changes: 6 additions & 2 deletions lib/queryFile.js
Expand Up @@ -265,11 +265,15 @@ function QueryFile(file, options) {
this.prepare();
}

// well-formatted output when passed into console.log():
// well-formatted output:
// - output the error message when in error state;
// - output the sql content when in normal state.
QueryFile.prototype.inspect = function () {
QueryFile.prototype.toString = function () {
return this.error ? this.error.message : this.query;
};

QueryFile.prototype.inspect = function () {
return this.toString();
};

module.exports = QueryFile;
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "pg-promise",
"version": "3.6.1",
"version": "3.6.2",
"description": "PostgreSQL via promises",
"main": "lib/index.js",
"scripts": {
Expand Down

0 comments on commit cf289f7

Please sign in to comment.