pg-promise 8.7.1 → 8.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -43,27 +43,20 @@ const npm = {
43
43
  *
44
44
  * @see ParameterizedQuery
45
45
  */
46
- function ParameterizedQueryError(error, ps) {
47
- const temp = Error.apply(this, arguments);
48
- temp.name = this.name = 'ParameterizedQueryError';
49
- this.stack = temp.stack;
50
- if (error instanceof npm.QueryFileError) {
51
- this.error = error;
52
- this.message = 'Failed to initialize \'text\' from a QueryFile.';
53
- } else {
54
- this.message = error;
46
+ class ParameterizedQueryError extends Error {
47
+ constructor(error, ps) {
48
+ const isQueryFileError = error instanceof npm.QueryFileError;
49
+ const message = isQueryFileError ? 'Failed to initialize \'text\' from a QueryFile.' : error;
50
+ super(message);
51
+ this.name = this.constructor.name;
52
+ if (isQueryFileError) {
53
+ this.error = error;
54
+ }
55
+ this.result = ps;
56
+ Error.captureStackTrace(this, this.constructor);
55
57
  }
56
- this.result = ps;
57
58
  }
58
59
 
59
- ParameterizedQueryError.prototype = Object.create(Error.prototype, {
60
- constructor: {
61
- value: ParameterizedQueryError,
62
- writable: true,
63
- configurable: true
64
- }
65
- });
66
-
67
60
  /**
68
61
  * @method errors.ParameterizedQueryError#toString
69
62
  * @description
@@ -43,27 +43,20 @@ const npm = {
43
43
  *
44
44
  * @see PreparedStatement
45
45
  */
46
- function PreparedStatementError(error, ps) {
47
- const temp = Error.apply(this, arguments);
48
- temp.name = this.name = 'PreparedStatementError';
49
- this.stack = temp.stack;
50
- if (error instanceof npm.QueryFileError) {
51
- this.error = error;
52
- this.message = 'Failed to initialize \'text\' from a QueryFile.';
53
- } else {
54
- this.message = error;
46
+ class PreparedStatementError extends Error {
47
+ constructor(error, ps) {
48
+ const isQueryFileError = error instanceof npm.QueryFileError;
49
+ const message = isQueryFileError ? 'Failed to initialize \'text\' from a QueryFile.' : error;
50
+ super(message);
51
+ this.name = this.constructor.name;
52
+ if (isQueryFileError) {
53
+ this.error = error;
54
+ }
55
+ this.result = ps;
56
+ Error.captureStackTrace(this, this.constructor);
55
57
  }
56
- this.result = ps;
57
58
  }
58
59
 
59
- PreparedStatementError.prototype = Object.create(Error.prototype, {
60
- constructor: {
61
- value: PreparedStatementError,
62
- writable: true,
63
- configurable: true
64
- }
65
- });
66
-
67
60
  /**
68
61
  * @method errors.PreparedStatementError#toString
69
62
  * @description
@@ -46,28 +46,21 @@ const npm = {
46
46
  * @see QueryFile
47
47
  *
48
48
  */
49
- function QueryFileError(error, qf) {
50
- const temp = Error.apply(this, arguments);
51
- temp.name = this.name = 'QueryFileError';
52
- this.stack = temp.stack;
53
- if (error instanceof npm.minify.SQLParsingError) {
54
- this.error = error;
55
- this.message = 'Failed to parse the SQL.';
56
- } else {
57
- this.message = error.message;
49
+ class QueryFileError extends Error {
50
+ constructor(error, qf) {
51
+ const isSqlError = error instanceof npm.minify.SQLParsingError;
52
+ const message = isSqlError ? 'Failed to parse the SQL.' : error.message;
53
+ super(message);
54
+ this.name = this.constructor.name;
55
+ if (isSqlError) {
56
+ this.error = error;
57
+ }
58
+ this.file = qf.file;
59
+ this.options = qf.options;
60
+ Error.captureStackTrace(this, this.constructor);
58
61
  }
59
- this.file = qf.file;
60
- this.options = qf.options;
61
62
  }
62
63
 
63
- QueryFileError.prototype = Object.create(Error.prototype, {
64
- constructor: {
65
- value: QueryFileError,
66
- writable: true,
67
- configurable: true
68
- }
69
- });
70
-
71
64
  /**
72
65
  * @method errors.QueryFileError#toString
73
66
  * @description
@@ -127,25 +127,19 @@ const errorMessages = [
127
127
  * {@link Database#oneOrNone oneOrNone}, {@link Database#many many}
128
128
  *
129
129
  */
130
- function QueryResultError(code, result, query, values) {
131
- const temp = Error.apply(this, arguments);
132
- temp.name = this.name = 'QueryResultError';
133
- this.stack = temp.stack;
134
- this.message = errorMessages[code].message;
135
- this.code = code;
136
- this.result = result;
137
- this.query = query;
138
- this.values = values;
139
- this.received = result.rows.length;
140
- }
141
-
142
- QueryResultError.prototype = Object.create(Error.prototype, {
143
- constructor: {
144
- value: QueryResultError,
145
- writable: true,
146
- configurable: true
130
+ class QueryResultError extends Error {
131
+ constructor(code, result, query, values) {
132
+ const message = errorMessages[code].message;
133
+ super(message);
134
+ this.name = this.constructor.name;
135
+ this.code = code;
136
+ this.result = result;
137
+ this.query = query;
138
+ this.values = values;
139
+ this.received = result.rows.length;
140
+ Error.captureStackTrace(this, this.constructor);
147
141
  }
148
- });
142
+ }
149
143
 
150
144
  /**
151
145
  * @method errors.QueryResultError#toString
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pg-promise",
3
- "version": "8.7.1",
3
+ "version": "8.7.2",
4
4
  "description": "Promises interface for PostgreSQL",
5
5
  "main": "lib/index.js",
6
6
  "typings": "typescript/pg-promise.d.ts",
@@ -44,7 +44,7 @@
44
44
  "assert-options": "0.1.3",
45
45
  "manakin": "0.5.2",
46
46
  "pg": "7.11.0",
47
- "pg-minify": "1.1.0",
47
+ "pg-minify": "1.2.0",
48
48
  "spex": "2.2.0"
49
49
  },
50
50
  "devDependencies": {