@stacksjs/error-handling 0.75.71 → 0.75.73
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -1
- package/dist/unique-violation.d.ts +21 -0
- package/dist/unique-violation.js +1 -0
- package/package.json +7 -7
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export*from"./bughq";export*from"./handler";export*from"./http";export*from"./model";export*from"./reporters";export*from"./utils";export{err,fromPromise,ok}from"ts-error-handling";export{ERROR_ILLUSTRATIONS,errorIllustration,illustrationForStatus}from"./error-illustrations";export{createErrorHandler,ERROR_PAGE_CSS,ErrorPageHandler,errorResponse,HTTP_ERRORS,renderError,renderErrorPage,renderHttpErrorHints,renderProductionErrorPage}from"./error-page";
|
|
1
|
+
export*from"./bughq";export*from"./handler";export*from"./http";export*from"./model";export*from"./reporters";export*from"./utils";export*from"./unique-violation";export{err,fromPromise,ok}from"ts-error-handling";export{ERROR_ILLUSTRATIONS,errorIllustration,illustrationForStatus}from"./error-illustrations";export{createErrorHandler,ERROR_PAGE_CSS,ErrorPageHandler,errorResponse,HTTP_ERRORS,renderError,renderErrorPage,renderHttpErrorHints,renderProductionErrorPage}from"./error-page";
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* True when the error is a unique-constraint violation, across SQLite,
|
|
3
|
+
* MySQL, and Postgres:
|
|
4
|
+
*
|
|
5
|
+
* - SQLite: `SQLITE_CONSTRAINT_UNIQUE` / `SQLITE_CONSTRAINT`
|
|
6
|
+
* - MySQL: `errno: 1062` (ER_DUP_ENTRY)
|
|
7
|
+
* - Postgres: `code: '23505'` (unique_violation)
|
|
8
|
+
* - Generic fallback: message text match — covers wrapped errors from drivers
|
|
9
|
+
* that lose the structured code.
|
|
10
|
+
*
|
|
11
|
+
* Lives here, in a package everything already depends on, because every
|
|
12
|
+
* write path that inserts behind a unique index needs it: the ORM's auto-CRUD
|
|
13
|
+
* routes and commerce writes (through `@stacksjs/orm`, which re-exports it),
|
|
14
|
+
* auth's `register()`, and the queue's idempotency and circuit-breaker tables.
|
|
15
|
+
* The queue had its own check that matched SQLite's and MySQL's wording only,
|
|
16
|
+
* so on Postgres a duplicate `dispatchOnce()` key threw instead of skipping.
|
|
17
|
+
*
|
|
18
|
+
* Exported for direct unit testing and for callers that map duplicates to
|
|
19
|
+
* their own error (e.g. `register()`'s 409) instead of swallowing them.
|
|
20
|
+
*/
|
|
21
|
+
export declare function isUniqueViolation(err: unknown): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function isUniqueViolation(err){const e=err;return e?.code==="SQLITE_CONSTRAINT_UNIQUE"||e?.code==="SQLITE_CONSTRAINT"||e?.code==="23505"||e?.errno===1062||/unique|duplicate/i.test(e?.message??"")}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stacksjs/error-handling",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.75.
|
|
4
|
+
"version": "0.75.73",
|
|
5
5
|
"description": "Type safe error handling.",
|
|
6
6
|
"author": "Chris Breuer",
|
|
7
7
|
"contributors": [
|
|
@@ -58,16 +58,16 @@
|
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
60
|
"@bughq/sdk": "^0.2.2",
|
|
61
|
-
"@stacksjs/path": "0.75.
|
|
62
|
-
"@stacksjs/stx": "^0.2.
|
|
63
|
-
"@stacksjs/types": "0.75.
|
|
61
|
+
"@stacksjs/path": "0.75.73",
|
|
62
|
+
"@stacksjs/stx": "^0.2.374",
|
|
63
|
+
"@stacksjs/types": "0.75.73",
|
|
64
64
|
"ts-error-handling": "^0.1.3",
|
|
65
65
|
"ts-syntax-highlighter": "^0.2.17"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
|
-
"@stacksjs/cli": "0.75.
|
|
69
|
-
"@stacksjs/config": "0.75.
|
|
70
|
-
"@stacksjs/validation": "0.75.
|
|
68
|
+
"@stacksjs/cli": "0.75.73",
|
|
69
|
+
"@stacksjs/config": "0.75.73",
|
|
70
|
+
"@stacksjs/validation": "0.75.73",
|
|
71
71
|
"better-dx": "^0.2.24"
|
|
72
72
|
},
|
|
73
73
|
"sideEffects": false
|