Skip to content

Commit

Permalink
Add stack traces to NeonDbError when captureStackTrace is available (#83
Browse files Browse the repository at this point in the history
)

Fixes #82
  • Loading branch information
brettimus authored Sep 27, 2024
1 parent d64b5c8 commit 6a9a2d2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## UNRELEASED

Capture stack traces in `NeonDbError`, if `Error.captureStackTrace` is available.

## 0.9.3 (2024-05-09)

Expose all error information fields on `NeonDbError` objects thrown when using the http fetch transport.
Expand Down
8 changes: 8 additions & 0 deletions export/httpQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ export class NeonDbError extends Error {
routine: string | undefined;

sourceError: Error | undefined;

constructor(message: string) {
super(message);

if ("captureStackTrace" in Error && typeof Error.captureStackTrace === "function") {
Error.captureStackTrace(this, NeonDbError);
}
}
}

interface ParameterizedQuery {
Expand Down

0 comments on commit 6a9a2d2

Please sign in to comment.