Skip to content

Incorrect constructor parameter types for class PostgresError #703

Closed

Description

@jaydenseric

According to the types, to construct a new PostgresError the first argument is a message string:

Screenshot 2023-10-20 at 10 14 32 am

With this code:

import postgres from "postgres";

const error = new postgres.PostgresError("Error message.");

console.log(Object.entries(error));

What actually logs is:

[
  [ '0', 'E' ],
  [ '1', 'r' ],
  [ '2', 'r' ],
  [ '3', 'o' ],
  [ '4', 'r' ],
  [ '5', ' ' ],
  [ '6', 'm' ],
  [ '7', 'e' ],
  [ '8', 's' ],
  [ '9', 's' ],
  [ '10', 'a' ],
  [ '11', 'g' ],
  [ '12', 'e' ],
  [ '13', '.' ],
  [ 'name', 'PostgresError' ]
]

That's because actually the first argument it seems is supposed to be an Error instance:

export class PostgresError extends Error {
constructor(x) {
super(x.message)
this.name = this.constructor.name
Object.assign(this, x)
}
}

Activity

  1. Nokel81 commented on Aug 19, 2026

    @Nokel81

    I just opened a PR to fix this as I just ran into this myself

  2. added a commit that references this issue on Oct 29, 2026
    06cf284
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions