This package has been deprecated

Author message:

This package is deprecated. Please use @yo1dog/psql-error instead.

@yo1dog/pg-error
TypeScript icon, indicating that this package has built-in type declarations

2.1.0 • Public • Published

pg-error

PG Error

Quick Start

const PGError = require('@yo1dog/pg-error');

const query = {
  text: `
    SELECT * FROM sometable
    LEFT JOIN othertable ON a = b
    WHERE c = $1
  `,
  values: ['D']
};
pgPool.query(query)
.catch(err => {
  throw new PGError(err, query);
});
PGError: relation "test" does not exist
 * FROM sometable\n    LEFT JOIN othertable ON a = b\n    WHERE c =
                                 ^
{
  length: 82,
  severity: 'ERROR',
  code: '42P01',
  position: '44',
  file: 'parse_relation.c',
  line: '1180',
  routine: 'parserOpenTable',
  query: {
    text: '\n' +
      '    SELECT * FROM sometable\n' +
      '    LEFT JOIN othertable ON a = b\n' +
      '    WHERE c = $1\n' +
      '  ',
    values: ['D']
  }
}
    at Object.<anonymous> (README.js:13:3)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)

Docs

new PGError(psqlError, [query])

param type description
psqlError Error Error from pg.
query string or object Query that caused error.

PGError.meta

PGError.origError

Readme

Keywords

none

Package Sidebar

Install

npm i @yo1dog/pg-error

Weekly Downloads

0

Version

2.1.0

License

ISC

Unpacked Size

7.08 kB

Total Files

5

Last publish

Collaborators

  • yo1dog