Skip to content

Better error reporting. Add original query and params to the thrown exception. #17

@davojan

Description

@davojan

Currently db exception looks like this:

Error: column "appliedat" of relation "some_table" does not exist
    at Object.generic (...backend/node_modules/postgres/lib/types.js:200:5)
    at Object.ErrorResponse (...backend/node_modules/postgres/lib/backend.js:124:33)
    at Socket.data (...backend/node_modules/postgres/lib/connection.js:161:25)
    at Socket.emit (events.js:223:5)
    at addChunk (_stream_readable.js:309:12)
    at readableAddChunk (_stream_readable.js:290:11)
    at Socket.Readable.push (_stream_readable.js:224:10)
    at TCP.onStreamRead (internal/stream_base_commons.js:181:23) {
  severity_local: 'ERROR',
  severity: 'ERROR',
  code: '42703',
  position: '40',
  file: 'parse_target.c',
  line: '1033',
  routine: 'checkInsertTargets'
}

There are two problems here:

  1. Stack trace doesn't tell anything about my own source code. Although async stack trace is enabled in node 12. May be node's socket API doesn't support async stack traces. It seems to be hard problem to solve and may be out of the scope of the library. But it should be considered.

  2. There is technical information from postgres server included, but no useful info about original query and params. I would be great if the query and params will be manually injected into the Error object before thrown to the app code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions