porsager / porsager/postgres

Incorrect constructor parameter types for class `PostgresError`

Open Beginner friendly
#703 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

help wanted Typescript
Dominant language
JavaScript
Stars
8.7k
Forks
374
Avg merge
11d 16h
Merged PRs (30d)
1

Description

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:

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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with src/errors.js at the constructor referenced in the issue, then compare its accepted argument with the published constructor types. Confirm the mismatch using the example from the report and make the runtime behavior and declared parameter types agree; existing checks should pass afterward.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, postgresql
Domain
databases
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
65/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.