From 8d5b70a219993515f156992099818914378db2fc Mon Sep 17 00:00:00 2001 From: Anders K Date: Wed, 1 Jun 2022 19:33:31 +0000 Subject: [PATCH 1/6] Throw errors, not strings --- src/api.js | 20 ++++++++++---------- src/worker.js | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/api.js b/src/api.js index 854bf32e..0cc5b166 100644 --- a/src/api.js +++ b/src/api.js @@ -311,11 +311,11 @@ Module["onRuntimeInitialized"] = function onRuntimeInitialized() { * @param {Statement.BindParams} values The values to bind * @return {boolean} true if it worked - * @throws {String} SQLite Error + * @throws {Error} SQLite Error */ Statement.prototype["bind"] = function bind(values) { if (!this.stmt) { - throw "Statement closed"; + throw new Error("Statement closed"); } this["reset"](); if (Array.isArray(values)) return this.bindFromArray(values); @@ -329,11 +329,11 @@ Module["onRuntimeInitialized"] = function onRuntimeInitialized() { that can be retrieved with {@link Statement.get}. @return {boolean} true if a row of result available - @throws {String} SQLite Error + @throws {Error} SQLite Error */ Statement.prototype["step"] = function step() { if (!this.stmt) { - throw "Statement closed"; + throw new Error("Statement closed"); } this.pos = 1; var ret = sqlite3_step(this.stmt); @@ -606,7 +606,7 @@ Module["onRuntimeInitialized"] = function onRuntimeInitialized() { default: break; } - throw ( + throw new Error( "Wrong API use : tried to bind a value of an unknown type (" + val + ")." ); @@ -738,7 +738,7 @@ Module["onRuntimeInitialized"] = function onRuntimeInitialized() { /** Prepare the next available SQL statement @return {StatementIterator.StatementIteratorResult} - @throws {String} SQLite error or invalid iterator error + @throws {Error} SQLite error or invalid iterator error */ StatementIterator.prototype["next"] = function next() { if (this.sqlPtr === null) { @@ -847,7 +847,7 @@ Module["onRuntimeInitialized"] = function onRuntimeInitialized() { */ Database.prototype["run"] = function run(sql, params) { if (!this.db) { - throw "Database closed"; + throw new Error("Database closed"); } if (params) { var stmt = this["prepare"](sql, params); @@ -930,7 +930,7 @@ Module["onRuntimeInitialized"] = function onRuntimeInitialized() { */ Database.prototype["exec"] = function exec(sql, params, config) { if (!this.db) { - throw "Database closed"; + throw new Error("Database closed"); } var stack = stackSave(); var stmt = null; @@ -1028,7 +1028,7 @@ Module["onRuntimeInitialized"] = function onRuntimeInitialized() { (`?`, `:VVV`, `:AAA`, `@AAA`) @param {Statement.BindParams} [params] values to bind to placeholders @return {Statement} the resulting statement - @throws {String} SQLite error + @throws {Error} SQLite error */ Database.prototype["prepare"] = function prepare(sql, params) { setValue(apiTemp, 0, "i32"); @@ -1036,7 +1036,7 @@ Module["onRuntimeInitialized"] = function onRuntimeInitialized() { // pointer to a statement, or null var pStmt = getValue(apiTemp, "i32"); if (pStmt === NULL) { - throw "Nothing to prepare"; + throw new Error("Nothing to prepare"); } var stmt = new Statement(pStmt, this); if (params != null) { diff --git a/src/worker.js b/src/worker.js index f75bf6a1..99ef7e73 100644 --- a/src/worker.js +++ b/src/worker.js @@ -29,7 +29,7 @@ function onModuleReady(SQL) { createDb(); } if (!data["sql"]) { - throw "exec: Missing query string"; + throw new Error("exec: Missing query string"); } return postMessage({ id: data["id"], From f71132bbc6fd4695a74305b6dab9e4280d248498 Mon Sep 17 00:00:00 2001 From: Anders K Date: Tue, 7 Jun 2022 19:01:30 +0000 Subject: [PATCH 2/6] Change package name --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 66238a9c..d11b3c6d 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "sql.js", + "name": "@and3k5/sql.js", "version": "1.7.0", "description": "SQLite library with support for opening and writing databases, prepared statements, and more. This SQLite library is in pure javascript (compiled with emscripten).", "keywords": [ From 176ec7c5e80a6502748466127d0af541a5572a75 Mon Sep 17 00:00:00 2001 From: Anders K Date: Tue, 7 Jun 2022 19:04:36 +0000 Subject: [PATCH 3/6] Delete CI.yml --- .github/workflows/CI.yml | 25 ------------------------- 1 file changed, 25 deletions(-) delete mode 100644 .github/workflows/CI.yml diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml deleted file mode 100644 index b29499de..00000000 --- a/.github/workflows/CI.yml +++ /dev/null @@ -1,25 +0,0 @@ -name: CI - -on: [push, pull_request] - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: make - uses: ./.github/actions/build-sqljs - - uses: actions/upload-artifact@v2 - with: {name: dist, path: dist} - - name: test - run: npm ci && npm test - - name: generate documentation - run: npm run doc - - name: Update github pages - if: github.event_name == 'push' && github.ref == 'refs/heads/master' - uses: JamesIves/github-pages-deploy-action@3.6.2 - with: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - BRANCH: gh-pages # The branch the action should deploy to. - FOLDER: "." # The folder the action should deploy. - CLEAN: false # Automatically remove deleted files from the deploy branch From 98d25562162be6d8829034cb244f78a3564e64dc Mon Sep 17 00:00:00 2001 From: Anders K Date: Tue, 7 Jun 2022 19:06:16 +0000 Subject: [PATCH 4/6] 1.7.1 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 02a7f276..fd73d4d7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "sql.js", - "version": "1.7.0", + "version": "1.7.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index d11b3c6d..a4929a44 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@and3k5/sql.js", - "version": "1.7.0", + "version": "1.7.1", "description": "SQLite library with support for opening and writing databases, prepared statements, and more. This SQLite library is in pure javascript (compiled with emscripten).", "keywords": [ "sql", From ae56fb88141bc1b47f316abbb335af0ad4a239ab Mon Sep 17 00:00:00 2001 From: Anders K Date: Tue, 7 Jun 2022 19:41:12 +0000 Subject: [PATCH 5/6] Set access to public --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9f846993..34f9475f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -80,6 +80,6 @@ jobs: - name: publish the package to NPM run: | npm config set '//registry.npmjs.org/:_authToken' "${NPM_TOKEN}" - npm publish + npm publish --access public env: NPM_TOKEN: ${{ secrets.NPM_TOKEN }} From 4897b3a270a886ed5bf38eb694c6cb7dbb0722ca Mon Sep 17 00:00:00 2001 From: Anders K Date: Tue, 7 Jun 2022 19:41:27 +0000 Subject: [PATCH 6/6] 1.7.2 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index fd73d4d7..2b6ebfae 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "sql.js", - "version": "1.7.1", + "version": "1.7.2", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index a4929a44..8c6d56f5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@and3k5/sql.js", - "version": "1.7.1", + "version": "1.7.2", "description": "SQLite library with support for opening and writing databases, prepared statements, and more. This SQLite library is in pure javascript (compiled with emscripten).", "keywords": [ "sql",