porsager / porsager/postgres

`console.log(error)` doesn't show full Postgres error

Open
#767 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Hey, not an issue since I solved it but think others might run into this.

I was trying to access the Postgres error for a foreign key constraint violation. I wasn't sure of the schema. So, I thought to print it but nothing worked:

      console.log(
        Object.keys(e),
        Object.getOwnPropertyNames(e),
        Object.getOwnPropertyDescriptors(e),
        Reflect.ownKeys(e),
      )

These all outputted: [ 'stack', 'query', 'parameters', 'args', 'types' ].

Ultimately looking at the type helped: https://github.com/porsager/postgres/blob/6f20a4820c683b33e7670b606d8daf5670f4b973/types/index.d.ts#L201

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 the linked types/index.d.ts location and inspect the declared error type and its properties. Compare that definition with the listed own keys to identify where the full PostgreSQL error details are exposed; the issue provides no requested code or documentation change to verify as done.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, nodejs, postgresql
Domain
databases
Issue type
Documentation
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
15/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.