@lunora/errors 1.0.0-alpha.2 → 1.0.0-alpha.4
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.mts +26 -2
- package/dist/index.d.ts +26 -2
- package/dist/index.mjs +5 -5
- package/dist/packem_shared/{ERROR_CATALOG-DAg3Unhb.mjs → ERROR_CATALOG-pJvm6SQP.mjs} +8 -3
- package/dist/packem_shared/{LunoraError-Dg03M4uC.mjs → LunoraError-Cdb2-Hda.mjs} +4 -4
- package/dist/packem_shared/{invariant-BsrkuTaN.mjs → invariant-HhlkSkbP.mjs} +1 -1
- package/dist/packem_shared/{isLunoraError-BvsoKcWE.mjs → isLunoraError-CSQtYMrF.mjs} +1 -1
- package/dist/packem_shared/{toErrorBody-BbR2r6pO.mjs → toErrorBody-BXvKCSrv.mjs} +2 -2
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -125,6 +125,23 @@ declare const ERROR_CATALOG: {
|
|
|
125
125
|
readonly status: 403;
|
|
126
126
|
readonly title: "RLS policy required";
|
|
127
127
|
};
|
|
128
|
+
readonly RUN_DEPTH_EXCEEDED: {
|
|
129
|
+
readonly internal: true;
|
|
130
|
+
readonly status: 500;
|
|
131
|
+
readonly title: "Run depth exceeded";
|
|
132
|
+
};
|
|
133
|
+
readonly MIGRATION_NOT_FOUND: {
|
|
134
|
+
readonly status: 404;
|
|
135
|
+
readonly title: "Data migration not found";
|
|
136
|
+
};
|
|
137
|
+
readonly UNKNOWN_TABLE: {
|
|
138
|
+
readonly status: 404;
|
|
139
|
+
readonly title: "Unknown table";
|
|
140
|
+
};
|
|
141
|
+
readonly GLOBAL_TABLE_NOT_EDITABLE: {
|
|
142
|
+
readonly status: 400;
|
|
143
|
+
readonly title: "Global table is not editable";
|
|
144
|
+
};
|
|
128
145
|
readonly SHARD_ERROR: {
|
|
129
146
|
readonly status: 503;
|
|
130
147
|
readonly title: "Shard error";
|
|
@@ -278,7 +295,7 @@ declare class LunoraError extends Error {
|
|
|
278
295
|
readonly title: string | undefined;
|
|
279
296
|
/** Source location, when known (mirrors `VisulimaError.loc`). */
|
|
280
297
|
readonly loc: ErrorLocation | undefined;
|
|
281
|
-
/** Machine-readable reason, keyed into
|
|
298
|
+
/** Machine-readable reason, keyed into `ERROR_CATALOG`. */
|
|
282
299
|
readonly code: string;
|
|
283
300
|
/** HTTP/RPC status for the transport mappers. */
|
|
284
301
|
readonly status: number;
|
|
@@ -295,8 +312,15 @@ interface LunoraErrorLike extends Error {
|
|
|
295
312
|
docsUrl?: string;
|
|
296
313
|
hint?: ErrorHint;
|
|
297
314
|
status: number;
|
|
315
|
+
/** Wire brand that distinguishes real `LunoraError`s from foreign errors. */
|
|
316
|
+
type: "VisulimaError";
|
|
298
317
|
}
|
|
299
|
-
/**
|
|
318
|
+
/**
|
|
319
|
+
* True when `error` carries the Lunora transport shape (string `code` + numeric
|
|
320
|
+
* `status` + the `VisulimaError` brand). The `type` brand is what distinguishes
|
|
321
|
+
* a real `LunoraError` (or its wire-decoded twin) from a foreign error that
|
|
322
|
+
* happens to carry `code`/`status` — see plan 119 for the full rationale.
|
|
323
|
+
*/
|
|
300
324
|
declare const isLunoraError: (error: unknown) => error is LunoraErrorLike;
|
|
301
325
|
/** Throw an `INTERNAL` {@link LunoraError} when `condition` is falsy. */
|
|
302
326
|
declare const invariant: (condition: unknown, message: string) => asserts condition;
|
package/dist/index.d.ts
CHANGED
|
@@ -125,6 +125,23 @@ declare const ERROR_CATALOG: {
|
|
|
125
125
|
readonly status: 403;
|
|
126
126
|
readonly title: "RLS policy required";
|
|
127
127
|
};
|
|
128
|
+
readonly RUN_DEPTH_EXCEEDED: {
|
|
129
|
+
readonly internal: true;
|
|
130
|
+
readonly status: 500;
|
|
131
|
+
readonly title: "Run depth exceeded";
|
|
132
|
+
};
|
|
133
|
+
readonly MIGRATION_NOT_FOUND: {
|
|
134
|
+
readonly status: 404;
|
|
135
|
+
readonly title: "Data migration not found";
|
|
136
|
+
};
|
|
137
|
+
readonly UNKNOWN_TABLE: {
|
|
138
|
+
readonly status: 404;
|
|
139
|
+
readonly title: "Unknown table";
|
|
140
|
+
};
|
|
141
|
+
readonly GLOBAL_TABLE_NOT_EDITABLE: {
|
|
142
|
+
readonly status: 400;
|
|
143
|
+
readonly title: "Global table is not editable";
|
|
144
|
+
};
|
|
128
145
|
readonly SHARD_ERROR: {
|
|
129
146
|
readonly status: 503;
|
|
130
147
|
readonly title: "Shard error";
|
|
@@ -278,7 +295,7 @@ declare class LunoraError extends Error {
|
|
|
278
295
|
readonly title: string | undefined;
|
|
279
296
|
/** Source location, when known (mirrors `VisulimaError.loc`). */
|
|
280
297
|
readonly loc: ErrorLocation | undefined;
|
|
281
|
-
/** Machine-readable reason, keyed into
|
|
298
|
+
/** Machine-readable reason, keyed into `ERROR_CATALOG`. */
|
|
282
299
|
readonly code: string;
|
|
283
300
|
/** HTTP/RPC status for the transport mappers. */
|
|
284
301
|
readonly status: number;
|
|
@@ -295,8 +312,15 @@ interface LunoraErrorLike extends Error {
|
|
|
295
312
|
docsUrl?: string;
|
|
296
313
|
hint?: ErrorHint;
|
|
297
314
|
status: number;
|
|
315
|
+
/** Wire brand that distinguishes real `LunoraError`s from foreign errors. */
|
|
316
|
+
type: "VisulimaError";
|
|
298
317
|
}
|
|
299
|
-
/**
|
|
318
|
+
/**
|
|
319
|
+
* True when `error` carries the Lunora transport shape (string `code` + numeric
|
|
320
|
+
* `status` + the `VisulimaError` brand). The `type` brand is what distinguishes
|
|
321
|
+
* a real `LunoraError` (or its wire-decoded twin) from a foreign error that
|
|
322
|
+
* happens to carry `code`/`status` — see plan 119 for the full rationale.
|
|
323
|
+
*/
|
|
300
324
|
declare const isLunoraError: (error: unknown) => error is LunoraErrorLike;
|
|
301
325
|
/** Throw an `INTERNAL` {@link LunoraError} when `condition` is falsy. */
|
|
302
326
|
declare const invariant: (condition: unknown, message: string) => asserts condition;
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { LunoraError } from './packem_shared/LunoraError-
|
|
2
|
-
export { ERROR_CATALOG, MESSAGE_SOLUTIONS, findSolutionByMessage, flattenHint, isInternalCode, resolveHint } from './packem_shared/ERROR_CATALOG-
|
|
3
|
-
export { isLunoraError } from './packem_shared/isLunoraError-
|
|
4
|
-
export { invariant, unreachable } from './packem_shared/invariant-
|
|
5
|
-
export { toErrorBody } from './packem_shared/toErrorBody-
|
|
1
|
+
export { LunoraError } from './packem_shared/LunoraError-Cdb2-Hda.mjs';
|
|
2
|
+
export { ERROR_CATALOG, MESSAGE_SOLUTIONS, findSolutionByMessage, flattenHint, isInternalCode, resolveHint } from './packem_shared/ERROR_CATALOG-pJvm6SQP.mjs';
|
|
3
|
+
export { isLunoraError } from './packem_shared/isLunoraError-CSQtYMrF.mjs';
|
|
4
|
+
export { invariant, unreachable } from './packem_shared/invariant-HhlkSkbP.mjs';
|
|
5
|
+
export { toErrorBody } from './packem_shared/toErrorBody-BXvKCSrv.mjs';
|
|
@@ -48,6 +48,10 @@ const ERROR_CATALOG = {
|
|
|
48
48
|
status: 403,
|
|
49
49
|
title: "RLS policy required"
|
|
50
50
|
},
|
|
51
|
+
RUN_DEPTH_EXCEEDED: { internal: true, status: 500, title: "Run depth exceeded" },
|
|
52
|
+
MIGRATION_NOT_FOUND: { status: 404, title: "Data migration not found" },
|
|
53
|
+
UNKNOWN_TABLE: { status: 404, title: "Unknown table" },
|
|
54
|
+
GLOBAL_TABLE_NOT_EDITABLE: { status: 400, title: "Global table is not editable" },
|
|
51
55
|
SHARD_ERROR: { status: 503, title: "Shard error" },
|
|
52
56
|
SHARD_UNAVAILABLE: { status: 503, title: "Shard unavailable" },
|
|
53
57
|
OFFLINE_IDENTITY_CHANGED: { status: 409, title: "Offline identity changed" },
|
|
@@ -69,7 +73,8 @@ const ERROR_CATALOG = {
|
|
|
69
73
|
R2_SQL_ERROR: { status: 502, title: "R2 SQL API error" },
|
|
70
74
|
WORKFLOWS_REST_ERROR: { status: 502, title: "Cloudflare Workflows REST API error" }
|
|
71
75
|
};
|
|
72
|
-
const
|
|
76
|
+
const getCatalogEntry = (code) => Object.hasOwn(ERROR_CATALOG, code) ? ERROR_CATALOG[code] : void 0;
|
|
77
|
+
const isInternalCode = (code) => getCatalogEntry(code)?.internal === true;
|
|
73
78
|
const MESSAGE_SOLUTIONS = [
|
|
74
79
|
{
|
|
75
80
|
body: [
|
|
@@ -209,7 +214,7 @@ const resolveHint = (input) => {
|
|
|
209
214
|
return input.hint;
|
|
210
215
|
}
|
|
211
216
|
if (input.code !== void 0) {
|
|
212
|
-
const entry =
|
|
217
|
+
const entry = getCatalogEntry(input.code);
|
|
213
218
|
if (entry?.hint !== void 0) {
|
|
214
219
|
return entry.hint;
|
|
215
220
|
}
|
|
@@ -217,4 +222,4 @@ const resolveHint = (input) => {
|
|
|
217
222
|
return input.message === void 0 ? void 0 : findSolutionByMessage(input.message)?.body;
|
|
218
223
|
};
|
|
219
224
|
|
|
220
|
-
export { ERROR_CATALOG, MESSAGE_SOLUTIONS, findSolutionByMessage, flattenHint, isInternalCode, resolveHint };
|
|
225
|
+
export { ERROR_CATALOG, MESSAGE_SOLUTIONS, findSolutionByMessage, flattenHint, getCatalogEntry, isInternalCode, resolveHint };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getCatalogEntry } from './ERROR_CATALOG-pJvm6SQP.mjs';
|
|
2
2
|
|
|
3
3
|
class LunoraError extends Error {
|
|
4
4
|
/**
|
|
@@ -13,7 +13,7 @@ class LunoraError extends Error {
|
|
|
13
13
|
title;
|
|
14
14
|
/** Source location, when known (mirrors `VisulimaError.loc`). */
|
|
15
15
|
loc;
|
|
16
|
-
/** Machine-readable reason, keyed into
|
|
16
|
+
/** Machine-readable reason, keyed into `ERROR_CATALOG`. */
|
|
17
17
|
code;
|
|
18
18
|
/** HTTP/RPC status for the transport mappers. */
|
|
19
19
|
status;
|
|
@@ -22,8 +22,8 @@ class LunoraError extends Error {
|
|
|
22
22
|
/** Optional structured payload propagated verbatim to the client. */
|
|
23
23
|
data;
|
|
24
24
|
constructor(code, message, options = {}) {
|
|
25
|
-
const entry =
|
|
26
|
-
super(message ?? code, { cause: options.cause });
|
|
25
|
+
const entry = getCatalogEntry(code);
|
|
26
|
+
super(message ?? code, options.cause === void 0 ? void 0 : { cause: options.cause });
|
|
27
27
|
this.name = options.name ?? "LunoraError";
|
|
28
28
|
this.hint = options.hint ?? entry?.hint;
|
|
29
29
|
this.title = options.title ?? entry?.title;
|
|
@@ -3,7 +3,7 @@ const isLunoraError = (error) => {
|
|
|
3
3
|
return false;
|
|
4
4
|
}
|
|
5
5
|
const candidate = error;
|
|
6
|
-
return typeof candidate.code === "string" && typeof candidate.status === "number";
|
|
6
|
+
return candidate.type === "VisulimaError" && typeof candidate.code === "string" && typeof candidate.status === "number";
|
|
7
7
|
};
|
|
8
8
|
|
|
9
9
|
export { isLunoraError };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { isInternalCode, resolveHint } from './ERROR_CATALOG-
|
|
2
|
-
import { isLunoraError } from './isLunoraError-
|
|
1
|
+
import { isInternalCode, resolveHint } from './ERROR_CATALOG-pJvm6SQP.mjs';
|
|
2
|
+
import { isLunoraError } from './isLunoraError-CSQtYMrF.mjs';
|
|
3
3
|
|
|
4
4
|
const toErrorBody = (error, options = {}) => {
|
|
5
5
|
const redactedMessage = options.redactedMessage ?? "Internal error";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lunora/errors",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.4",
|
|
4
4
|
"description": "Unified error layer for Lunora: one LunoraError base + a central catalog of codes, statuses, and actionable hints, rendered across CLI, overlay, Studio, and the client",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare",
|