porsager/postgres

Incorrect constructor parameter types for class `PostgresError`

Open

#703 ouverte le 19 oct. 2023

Voir sur GitHub
 (0 commentaires) (0 réactions) (0 assignés)JavaScript (230 forks)batch import
Typescripthelp wanted

Métriques du dépôt

Stars
 (6 221 stars)
Métriques de merge PR
 (Aucune PR mergée en 30 j)

Description

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

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:

https://github.com/porsager/postgres/blob/0428b30937400a7dadc8ed09587c44ef917052a6/src/errors.js#L1-L7

Guide contributeur