Skip to content

Reporting original execution context #20

@olivierlacan

Description

@olivierlacan

I'm not quite sure whether this library is the right place to surface this information but I find myself a bit baffled at a UniqueViolationError it throws with no context regarding which of my application code might be responsible since it only preserves stack frames from db-errors and objection and not my original call site.

Example:

  1) ProjectTaskDVSV1Publisher
       "before each" hook for "builds a message that matches the schema":
     UniqueViolationError: insert into "requirements" ("created_at", "description", "id", "name", "updated_at") values ($1, $2, $3, $4, $5) returning * - duplicate key value violates unique constraint "requirements_pkey"
      at wrapError (node_modules/db-errors/lib/dbErrors.js:19:14)
      at handleExecuteError (node_modules/objection/lib/queryBuilder/QueryBuilder.js:1494:32)
      at QueryBuilder.execute (node_modules/objection/lib/queryBuilder/QueryBuilder.js:685:13)
      at processTicksAndRejections (internal/process/task_queues.js:97:5)

I'd be much more actionable if the call site that caused the exception could be included in the stacktrace or at least referenced in the error itself in some way (as a property perhaps). This may be entirely beyond the scope of this project, but I had to ask.

So for instance, given the following call site:

requirement = await Requirement.query()
      .insert({
        ...requirementAttrs
      })
      .returning('*');

I would expect the UniqueViolationError to lead me to this code somehow.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions