Comparing version
@@ -7,2 +7,3 @@ "use strict"; | ||
const strings_1 = require("./utils/strings"); | ||
const format_error_1 = require("./utils/format-error"); | ||
/** | ||
@@ -45,3 +46,3 @@ * Promisified wrapper for the sqlite3#Database interface. | ||
if (err) { | ||
return reject(err); | ||
return reject((0, format_error_1.formatError)(err)); | ||
} | ||
@@ -54,3 +55,3 @@ resolve(); | ||
if (err) { | ||
return reject(err); | ||
return reject((0, format_error_1.formatError)(err)); | ||
} | ||
@@ -69,3 +70,3 @@ resolve(); | ||
if (err) { | ||
return reject(err); | ||
return reject((0, format_error_1.formatError)(err)); | ||
} | ||
@@ -101,3 +102,3 @@ resolve(); | ||
if (err) { | ||
return reject(err); | ||
return reject((0, format_error_1.formatError)(err)); | ||
} | ||
@@ -134,3 +135,3 @@ resolve({ | ||
if (err) { | ||
return reject(err); | ||
return reject((0, format_error_1.formatError)(err)); | ||
} | ||
@@ -157,3 +158,3 @@ resolve(row); | ||
if (err) { | ||
return callback(err, null); | ||
return callback((0, format_error_1.formatError)(err), null); | ||
} | ||
@@ -163,3 +164,3 @@ callback(null, row); | ||
if (err) { | ||
return reject(err); | ||
return reject((0, format_error_1.formatError)(err)); | ||
} | ||
@@ -198,3 +199,3 @@ resolve(count); | ||
if (err) { | ||
return reject(err); | ||
return reject((0, format_error_1.formatError)(err)); | ||
} | ||
@@ -222,3 +223,3 @@ resolve(rows); | ||
if (err) { | ||
return reject(err); | ||
return reject((0, format_error_1.formatError)(err)); | ||
} | ||
@@ -261,3 +262,3 @@ resolve(); | ||
if (err) { | ||
return reject(err); | ||
return reject((0, format_error_1.formatError)(err)); | ||
} | ||
@@ -264,0 +265,0 @@ resolve(); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Statement = void 0; | ||
const format_error_1 = require("./utils/format-error"); | ||
/** | ||
@@ -27,3 +28,3 @@ * Promisified wrapper for the sqlite3#Statement interface. | ||
if (err) { | ||
return reject(err); | ||
return reject((0, format_error_1.formatError)(err)); | ||
} | ||
@@ -56,3 +57,3 @@ resolve(); | ||
if (err) { | ||
return reject(err); | ||
return reject((0, format_error_1.formatError)(err)); | ||
} | ||
@@ -83,3 +84,3 @@ resolve(); | ||
if (err) { | ||
return reject(err); | ||
return reject((0, format_error_1.formatError)(err)); | ||
} | ||
@@ -113,3 +114,3 @@ resolve({ | ||
if (err) { | ||
return reject(err); | ||
return reject((0, format_error_1.formatError)(err)); | ||
} | ||
@@ -140,3 +141,3 @@ resolve(row); | ||
if (err) { | ||
return reject(err); | ||
return reject((0, format_error_1.formatError)(err)); | ||
} | ||
@@ -162,3 +163,3 @@ resolve(rows); | ||
if (err) { | ||
return callback(err, null); | ||
return callback((0, format_error_1.formatError)(err), null); | ||
} | ||
@@ -168,3 +169,3 @@ callback(null, row); | ||
if (err) { | ||
return reject(err); | ||
return reject((0, format_error_1.formatError)(err)); | ||
} | ||
@@ -171,0 +172,0 @@ resolve(count); |
@@ -0,1 +1,16 @@ | ||
## 4.1.1 - Sun Apr 24 2022 00:00:52 | ||
**Contributor:** Theo Gravity | ||
- Have native sqlite errors contain stack traces (#162) | ||
This ensures that errors thrown from the sqlite driver now | ||
have stack traces and are of an `Error` type. | ||
Thanks to @fresheneesz for initial troubleshooting and initial | ||
code to help fix the issue. | ||
This is a minor level version update as to not break implementations | ||
that may handle errors in their own way prior to this fix. | ||
## 4.0.25 - Mon Mar 07 2022 08:50:06 | ||
@@ -2,0 +17,0 @@ |
{ | ||
"name": "sqlite", | ||
"version": "4.0.25", | ||
"version": "4.1.1", | ||
"description": "SQLite client for Node.js applications with SQL-based migrations API written in Typescript", | ||
@@ -76,7 +76,7 @@ "main": "build/index.js", | ||
"@types/jest": "27.4.1", | ||
"@types/node": "^17.0.21", | ||
"@types/node": "^17.0.25", | ||
"@types/sqlite3": "^3.1.8", | ||
"@typescript-eslint/eslint-plugin": "^4.20.0", | ||
"@typescript-eslint/parser": "^4.20.0", | ||
"eslint": "7.23.0", | ||
"@typescript-eslint/eslint-plugin": "^5.20.0", | ||
"@typescript-eslint/parser": "^5.20.0", | ||
"eslint": "8.14.0", | ||
"git-commit-stamper": "^1.0.10", | ||
@@ -86,16 +86,16 @@ "jest": "27.5.1", | ||
"jest-junit-reporter": "1.1.0", | ||
"lint-staged": "12.3.5", | ||
"lint-staged": "12.4.0", | ||
"pre-commit": "1.2.2", | ||
"prettier-standard": "16.4.1", | ||
"sql-template-strings": "^2.2.2", | ||
"sqlite3": "^5.0.2", | ||
"sqlite3": "^5.0.5", | ||
"sqlite3-offline-next": "^5.0.3", | ||
"standardx": "^7.0.0", | ||
"toc-md-alt": "^0.4.6", | ||
"ts-jest": "27.1.3", | ||
"ts-jest": "27.1.4", | ||
"ts-node": "10.7.0", | ||
"ts-node-dev": "1.1.8", | ||
"typedoc": "^0.22.13", | ||
"typedoc-plugin-markdown": "^3.11.14", | ||
"typescript": "4.6.2", | ||
"typedoc": "^0.22.15", | ||
"typedoc-plugin-markdown": "^3.12.1", | ||
"typescript": "4.6.3", | ||
"version-bump-plugin-git": "^2.0.1" | ||
@@ -102,0 +102,0 @@ }, |
@@ -354,3 +354,3 @@ # SQLite Client for Node.js Apps | ||
`each()` is a bit different compared to the other operations. | ||
`each()` is a bit different compared to the other operations due to its underlying [implementation](https://github.com/TryGhost/node-sqlite3/wiki/API#databaseeachsql-param--callback-complete). | ||
@@ -365,14 +365,20 @@ The function signature looks like this: | ||
```typescript | ||
const rowsCount = await db.each( | ||
'SELECT col FROM tbl WHERE ROWID = ?', | ||
[2], | ||
(err, row) => { | ||
if (err) { | ||
throw err | ||
try { | ||
// You need to wrap this in a try / catch for SQL parse / connection errors | ||
const rowsCount = await db.each( | ||
'SELECT col FROM tbl WHERE ROWID = ?', | ||
[2], | ||
(err, row) => { | ||
if (err) { | ||
// This would be if there is an error specific to the row result | ||
throw err | ||
} | ||
// row = { col: 'other thing' } | ||
} | ||
) | ||
} catch (e) { | ||
throw e | ||
} | ||
// row = { col: 'other thing' } | ||
} | ||
) | ||
// rowsCount = 1 | ||
@@ -379,0 +385,0 @@ ``` |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
98052
3.42%28
12%1254
2.2%532
1.14%