Skip to content

Commit

Permalink
Keep query error instead of creating creating new object (#698)
Browse files Browse the repository at this point in the history
* Keep query error instead of creating creating new object

fixes #696

* Enumerate properties only if debug

* Fixed typo

* Fixed styling
  • Loading branch information
Pyrolistical committed Oct 26, 2023
1 parent 0bee4c3 commit f2fb819
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/connection.js
Expand Up @@ -385,13 +385,14 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose
}

function queryError(query, err) {
query.reject(Object.create(err, {
Object.defineProperties(err, {
stack: { value: err.stack + query.origin.replace(/.*\n/, '\n'), enumerable: options.debug },
query: { value: query.string, enumerable: options.debug },
parameters: { value: query.parameters, enumerable: options.debug },
args: { value: query.args, enumerable: options.debug },
types: { value: query.statement && query.statement.types, enumerable: options.debug }
}))
})
query.reject(err)
}

function end() {
Expand Down

0 comments on commit f2fb819

Please sign in to comment.