@stacksjs/error-handling 0.75.383 → 0.75.388

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.
@@ -19,3 +19,14 @@
19
19
  * their own error (e.g. `register()`'s 409) instead of swallowing them.
20
20
  */
21
21
  export declare function isUniqueViolation(err: unknown): boolean;
22
+ /**
23
+ * True when the error is a NOT NULL violation, across SQLite, MySQL and Postgres:
24
+ *
25
+ * - SQLite: `SQLITE_CONSTRAINT_NOTNULL`, or "NOT NULL constraint failed"
26
+ * - MySQL: `errno: 1048` (ER_BAD_NULL_ERROR) and `1364` (ER_NO_DEFAULT_FOR_FIELD)
27
+ * - Postgres: `code: '23502'` (not_null_violation)
28
+ *
29
+ * A required column that a request left out is the caller's mistake, not a
30
+ * server fault, so write paths answer it with a 422 instead of a 500.
31
+ */
32
+ export declare function isNotNullViolation(err: unknown): boolean;
@@ -1 +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??"")}
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??"")}export function isNotNullViolation(err){const e=err;return e?.code==="SQLITE_CONSTRAINT_NOTNULL"||e?.code==="23502"||e?.errno===1048||e?.errno===1364||/not null constraint failed|cannot be null|null value in column|doesn't have a default value/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.383",
4
+ "version": "0.75.388",
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.3.0",
61
- "@stacksjs/config": "0.75.383",
62
- "@stacksjs/path": "0.75.383",
61
+ "@stacksjs/config": "0.75.388",
62
+ "@stacksjs/path": "0.75.388",
63
63
  "@stacksjs/stx": "0.2.752",
64
- "@stacksjs/types": "0.75.383",
64
+ "@stacksjs/types": "0.75.388",
65
65
  "ts-error-handling": "^0.1.3",
66
66
  "ts-syntax-highlighter": "^0.2.17"
67
67
  },
68
68
  "devDependencies": {
69
- "@stacksjs/cli": "0.75.383",
70
- "@stacksjs/validation": "0.75.383",
69
+ "@stacksjs/cli": "0.75.388",
70
+ "@stacksjs/validation": "0.75.388",
71
71
  "better-dx": "^0.2.24"
72
72
  },
73
73
  "sideEffects": false