@lunora/errors 1.0.0-alpha.2 → 1.0.0-alpha.20
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 +630 -79
- package/dist/index.d.ts +630 -79
- package/dist/index.mjs +1 -5
- package/dist/packem_shared/CLOUDFLARE_PLATFORM_ERRORS-BTERKAHF.mjs +15 -0
- package/dist/packem_shared/LunoraError-DfLzV9qB.mjs +1 -0
- package/dist/packem_shared/invariant-DAlZGOIJ.mjs +1 -0
- package/dist/packem_shared/isLunoraError-Dvew97xn.mjs +1 -0
- package/dist/packem_shared/toErrorBody-BO0HFiCR.mjs +1 -0
- package/package.json +1 -1
- package/dist/packem_shared/ERROR_CATALOG-DAg3Unhb.mjs +0 -220
- package/dist/packem_shared/LunoraError-Dg03M4uC.mjs +0 -38
- package/dist/packem_shared/invariant-BsrkuTaN.mjs +0 -12
- package/dist/packem_shared/isLunoraError-BvsoKcWE.mjs +0 -9
- package/dist/packem_shared/toErrorBody-BbR2r6pO.mjs +0 -26
package/dist/index.d.mts
CHANGED
|
@@ -1,18 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The central Lunora error catalog — the single source of truth mapping a
|
|
3
|
-
* machine-readable `code` to its transport `status`, a short human `title`, and
|
|
4
|
-
* (where useful) an actionable Markdown `hint` plus a `docsUrl`.
|
|
5
|
-
*
|
|
6
|
-
* This table is consumed everywhere an error is surfaced: the runtime/DO wire
|
|
7
|
-
* mappers (status), the client SDK (code discrimination), the CLI renderer and
|
|
8
|
-
* the Vite overlay (hint), and the Studio UI (title + hint + docs link). It also
|
|
9
|
-
* absorbs the former `@lunora/codegen` "solutions" table (see {@link MESSAGE_SOLUTIONS})
|
|
10
|
-
* so codegen build-time errors — which are thrown as plain messages into
|
|
11
|
-
* generated code and lose their class identity before a consumer sees them —
|
|
12
|
-
* keep their message-matched hints.
|
|
13
|
-
*/
|
|
14
1
|
/** Markdown hint: a single string or an array of lines. Shape matches `@visulima/error`'s `hint`. */
|
|
15
|
-
type ErrorHint = string | string
|
|
2
|
+
type ErrorHint = string | ReadonlyArray<string>;
|
|
16
3
|
/** A catalog entry: the fixed metadata for one error `code`. */
|
|
17
4
|
interface ErrorCatalogEntry {
|
|
18
5
|
/** Optional URL to deeper docs for this error. */
|
|
@@ -20,11 +7,11 @@ interface ErrorCatalogEntry {
|
|
|
20
7
|
/** Optional actionable fix, authored as Markdown (rendered by CLI/overlay/Studio). */
|
|
21
8
|
hint?: ErrorHint;
|
|
22
9
|
/**
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
10
|
+
* When `true`, this code's `message` must NOT cross the wire — an internal
|
|
11
|
+
* failure or unhandled invariant may carry SQL fragments, file paths, or
|
|
12
|
+
* internal identifiers. The transport mappers emit a generic message for
|
|
13
|
+
* these (and log the real one server-side). See {@link isInternalCode}.
|
|
14
|
+
*/
|
|
28
15
|
internal?: boolean;
|
|
29
16
|
/** HTTP/RPC status this code maps to on the wire. */
|
|
30
17
|
status: number;
|
|
@@ -32,10 +19,10 @@ interface ErrorCatalogEntry {
|
|
|
32
19
|
title: string;
|
|
33
20
|
}
|
|
34
21
|
/**
|
|
35
|
-
* Every well-known Lunora error code. Domain packages may throw additional
|
|
36
|
-
* codes (passing an explicit `status`); those are added here as their package is
|
|
37
|
-
* migrated. The keys of this object form the {@link LunoraErrorCode} union.
|
|
38
|
-
*/
|
|
22
|
+
* Every well-known Lunora error code. Domain packages may throw additional
|
|
23
|
+
* codes (passing an explicit `status`); those are added here as their package is
|
|
24
|
+
* migrated. The keys of this object form the {@link LunoraErrorCode} union.
|
|
25
|
+
*/
|
|
39
26
|
declare const ERROR_CATALOG: {
|
|
40
27
|
readonly BAD_REQUEST: {
|
|
41
28
|
readonly status: 400;
|
|
@@ -78,7 +65,8 @@ declare const ERROR_CATALOG: {
|
|
|
78
65
|
readonly NOT_IMPLEMENTED: {
|
|
79
66
|
readonly status: 501;
|
|
80
67
|
readonly title: "Not implemented";
|
|
81
|
-
};
|
|
68
|
+
};
|
|
69
|
+
/** RPC/REST dispatch codes emitted by the runtime + Durable Object router. */
|
|
82
70
|
readonly FUNCTION_NOT_FOUND: {
|
|
83
71
|
readonly status: 404;
|
|
84
72
|
readonly title: "Function not found";
|
|
@@ -90,7 +78,8 @@ declare const ERROR_CATALOG: {
|
|
|
90
78
|
readonly PAYLOAD_TOO_LARGE: {
|
|
91
79
|
readonly status: 413;
|
|
92
80
|
readonly title: "Payload too large";
|
|
93
|
-
};
|
|
81
|
+
};
|
|
82
|
+
/** Free-form internal failure — redacted to a generic message on the wire. */
|
|
94
83
|
readonly INTERNAL: {
|
|
95
84
|
readonly internal: true;
|
|
96
85
|
readonly status: 500;
|
|
@@ -125,6 +114,28 @@ declare const ERROR_CATALOG: {
|
|
|
125
114
|
readonly status: 403;
|
|
126
115
|
readonly title: "RLS policy required";
|
|
127
116
|
};
|
|
117
|
+
readonly RUN_DEPTH_EXCEEDED: {
|
|
118
|
+
readonly internal: true;
|
|
119
|
+
readonly status: 500;
|
|
120
|
+
readonly title: "Run depth exceeded";
|
|
121
|
+
};
|
|
122
|
+
readonly TRANSACTION_LIMIT_EXCEEDED: {
|
|
123
|
+
readonly hint: readonly ["A single mutation may only read and write a bounded amount before it is stopped.", "", "Narrow the read with an index (`.withIndex(...)`) instead of scanning the table, or split the write across several mutations — for a large backfill use `defineMigration` + `lunora migrate up`, which batches and checkpoints for you.", "", "The ceilings are deliberately conservative — they exist to stop one request taking down the whole shard. A deployment that genuinely needs bigger transactions can raise them by overriding the `transactionLimits()` seam on its generated shard class."];
|
|
124
|
+
readonly status: 413;
|
|
125
|
+
readonly title: "Transaction limit exceeded";
|
|
126
|
+
};
|
|
127
|
+
readonly MIGRATION_NOT_FOUND: {
|
|
128
|
+
readonly status: 404;
|
|
129
|
+
readonly title: "Data migration not found";
|
|
130
|
+
};
|
|
131
|
+
readonly UNKNOWN_TABLE: {
|
|
132
|
+
readonly status: 404;
|
|
133
|
+
readonly title: "Unknown table";
|
|
134
|
+
};
|
|
135
|
+
readonly GLOBAL_TABLE_NOT_EDITABLE: {
|
|
136
|
+
readonly status: 400;
|
|
137
|
+
readonly title: "Global table is not editable";
|
|
138
|
+
};
|
|
128
139
|
readonly SHARD_ERROR: {
|
|
129
140
|
readonly status: 503;
|
|
130
141
|
readonly title: "Shard error";
|
|
@@ -136,7 +147,8 @@ declare const ERROR_CATALOG: {
|
|
|
136
147
|
readonly OFFLINE_IDENTITY_CHANGED: {
|
|
137
148
|
readonly status: 409;
|
|
138
149
|
readonly title: "Offline identity changed";
|
|
139
|
-
};
|
|
150
|
+
};
|
|
151
|
+
/** Package-specific codes. Build-time-only — never cross the RPC wire, so deliberately not `internal`. */
|
|
140
152
|
readonly CODEGEN_DIAGNOSTIC: {
|
|
141
153
|
readonly status: 500;
|
|
142
154
|
readonly title: "Codegen diagnostic";
|
|
@@ -159,11 +171,31 @@ declare const ERROR_CATALOG: {
|
|
|
159
171
|
readonly title: "Auth headers missing";
|
|
160
172
|
};
|
|
161
173
|
/**
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
174
|
+
* Signup rejected by `@lunora/auth`'s email-domain gate — a disposable/throwaway
|
|
175
|
+
* provider (or a caller deny-list hit). Client-safe: the message names only the
|
|
176
|
+
* offending domain class, never a secret, so it is echoed rather than redacted.
|
|
177
|
+
*/
|
|
178
|
+
readonly EMAIL_DOMAIN_BLOCKED: {
|
|
179
|
+
readonly hint: readonly ["This address's domain is on the disposable/throwaway blocklist (or your configured deny-list).", "", "Sign up with a permanent mailbox. To tune the policy, pass `blockDisposable` / `allowDomains` / `denyDomains` to `emailGate(...)` (`@lunora/auth/email-guard`)."];
|
|
180
|
+
readonly status: 400;
|
|
181
|
+
readonly title: "Email domain not allowed";
|
|
182
|
+
};
|
|
183
|
+
/**
|
|
184
|
+
* Opt-in MX verification (`@lunora/auth/email-guard`, `mx: true`) found no mail
|
|
185
|
+
* exchanger for the address's domain, so mail to it would never deliver.
|
|
186
|
+
* Client-safe: names only the domain, no secret.
|
|
187
|
+
*/
|
|
188
|
+
readonly EMAIL_UNDELIVERABLE: {
|
|
189
|
+
readonly hint: readonly ["The address's domain publishes no MX (or fallback A/AAAA) records, so it can't receive mail.", "", "Check for a typo in the domain. MX verification is opt-in (`mx: true`) and needs DNS — leave it off on the edge path if DNS is unavailable."];
|
|
190
|
+
readonly status: 400;
|
|
191
|
+
readonly title: "Email domain cannot receive mail";
|
|
192
|
+
};
|
|
193
|
+
/**
|
|
194
|
+
* Upstream Cloudflare API failures surfaced from an action. The message
|
|
195
|
+
* carries the upstream response body (Cloudflare's own error text — trusted
|
|
196
|
+
* infra, not user input), so it is echoed rather than redacted. `status`
|
|
197
|
+
* here is a fallback; each throw passes the actual upstream HTTP status.
|
|
198
|
+
*/
|
|
167
199
|
readonly ANALYTICS_SQL_ERROR: {
|
|
168
200
|
readonly status: 502;
|
|
169
201
|
readonly title: "Analytics Engine SQL API error";
|
|
@@ -176,25 +208,472 @@ declare const ERROR_CATALOG: {
|
|
|
176
208
|
readonly status: 502;
|
|
177
209
|
readonly title: "Cloudflare Workflows REST API error";
|
|
178
210
|
};
|
|
211
|
+
/**
|
|
212
|
+
* Admin-gated `/_lunora/admin/*` and `__lunora_admin__:*` codes. Registered
|
|
213
|
+
* here (plan 230, ERRORS-01) after an audit found them minted with `code:`
|
|
214
|
+
* but never added to the catalog — `isInternalCode` fails OPEN for an
|
|
215
|
+
* unregistered code, so each was already echoing its message unredacted.
|
|
216
|
+
* Below is that audit's verdict per code, not a blanket allow: most of these
|
|
217
|
+
* are deliberately actionable ("you forgot to configure X") and stay
|
|
218
|
+
* client-safe; the ones that can carry backend detail are flagged
|
|
219
|
+
* `internal: true` individually, with the reason noted alongside.
|
|
220
|
+
*/
|
|
221
|
+
readonly ADMIN_FORBIDDEN: {
|
|
222
|
+
readonly status: 403;
|
|
223
|
+
readonly title: "Admin access forbidden";
|
|
224
|
+
};
|
|
225
|
+
readonly ADMIN_TOKEN_NOT_CONFIGURED: {
|
|
226
|
+
readonly status: 400;
|
|
227
|
+
readonly title: "Admin token not configured";
|
|
228
|
+
};
|
|
229
|
+
readonly AUTH_NOT_CONFIGURED: {
|
|
230
|
+
readonly status: 400;
|
|
231
|
+
readonly title: "Auth admin not configured";
|
|
232
|
+
};
|
|
233
|
+
readonly AUTH_OP_NOT_SUPPORTED: {
|
|
234
|
+
readonly status: 400;
|
|
235
|
+
readonly title: "Auth admin operation not supported";
|
|
236
|
+
};
|
|
237
|
+
readonly BACKUP_NOT_CONFIGURED: {
|
|
238
|
+
readonly status: 500;
|
|
239
|
+
readonly title: "Scheduled backup not configured";
|
|
240
|
+
};
|
|
241
|
+
readonly BACKUP_RETENTION_NOT_CONFIGURED: {
|
|
242
|
+
readonly hint: readonly ["`lunora backup prune` removes snapshots past the retention window, and this worker has no window: set `backupRetain` (how many to keep) and `backupCron` (which decides whose snapshots retention owns) on `createWorker`.", "", "Nothing was deleted. A default is deliberately not invented here — retention deleting on its own is exactly what this command exists to replace."];
|
|
243
|
+
readonly status: 400;
|
|
244
|
+
readonly title: "Backup retention window not configured";
|
|
245
|
+
};
|
|
246
|
+
readonly BACKUP_TOO_LARGE: {
|
|
247
|
+
readonly hint: readonly ["The scheduled backup is assembled inside the Worker isolate, so it caps the snapshot it will build. Nothing was written.", "", "The cap is on the NDJSON, not on peak memory: the export fan-out resolves every shard's rows before the first row is encoded, so a snapshot under the cap can still exhaust the isolate. It is set well below the isolate's limit for that reason.", "", "Narrow the snapshot with `backupTables`, or take this backup off-platform with `lunora backup create --bucket`, which runs on a machine rather than in an isolate. Backing up more often does not help — every run is a full snapshot."];
|
|
248
|
+
readonly status: 507;
|
|
249
|
+
readonly title: "Backup too large to assemble in a Worker";
|
|
250
|
+
};
|
|
251
|
+
readonly CRON_JOBS_NOT_CONFIGURED: {
|
|
252
|
+
readonly status: 400;
|
|
253
|
+
readonly title: "Cron jobs not configured";
|
|
254
|
+
};
|
|
255
|
+
readonly CRON_JOB_NOT_FOUND: {
|
|
256
|
+
readonly status: 404;
|
|
257
|
+
readonly title: "Cron job not found";
|
|
258
|
+
};
|
|
259
|
+
readonly EXPORT_TAP_NOT_CONFIGURED: {
|
|
260
|
+
readonly status: 400;
|
|
261
|
+
readonly title: "Export tap not configured";
|
|
262
|
+
};
|
|
263
|
+
readonly FUNCTIONS_NOT_CONFIGURED: {
|
|
264
|
+
readonly status: 400;
|
|
265
|
+
readonly title: "Functions registry not configured";
|
|
266
|
+
};
|
|
267
|
+
readonly GLOBALS_NOT_CONFIGURED: {
|
|
268
|
+
readonly status: 400;
|
|
269
|
+
readonly title: "Global-table introspector not configured";
|
|
270
|
+
};
|
|
271
|
+
readonly KV_NOT_CONFIGURED: {
|
|
272
|
+
readonly status: 400;
|
|
273
|
+
readonly title: "KV introspector not configured";
|
|
274
|
+
};
|
|
275
|
+
readonly MIGRATION_ID_REQUIRED: {
|
|
276
|
+
readonly status: 400;
|
|
277
|
+
readonly title: "Migration id required";
|
|
278
|
+
};
|
|
279
|
+
readonly PITR_UNAVAILABLE: {
|
|
280
|
+
readonly status: 409;
|
|
281
|
+
readonly title: "Point-in-time recovery unavailable";
|
|
282
|
+
};
|
|
283
|
+
readonly SCHEDULER_NOT_CONFIGURED: {
|
|
284
|
+
readonly status: 400;
|
|
285
|
+
readonly title: "Scheduler not configured";
|
|
286
|
+
};
|
|
287
|
+
readonly STORAGE_CHECKSUM_MISMATCH: {
|
|
288
|
+
readonly hint: readonly ["The upload body did not match the declared `expectedSize` or `expectedSha256`, so nothing was written — this check fails closed.", "", "Re-read the bytes from the source export and retry the transfer. A persistent mismatch means the source blob is corrupt or truncated; fix the export rather than bypassing the check."];
|
|
289
|
+
readonly status: 400;
|
|
290
|
+
readonly title: "Storage checksum mismatch";
|
|
291
|
+
};
|
|
292
|
+
readonly STORAGE_DELETE_NOT_CONFIGURED: {
|
|
293
|
+
readonly status: 400;
|
|
294
|
+
readonly title: "Storage delete not configured";
|
|
295
|
+
};
|
|
296
|
+
readonly STORAGE_DOWNLOAD_NOT_CONFIGURED: {
|
|
297
|
+
readonly hint: readonly ["`GET /_lunora/admin/storage/object` needs a `storageDownload` function on the worker. The generated app worker wires it up; a hand-written `createWorker({ ... })` has to pass `(key, opts) => pick(opts?.bucket).download(key)` — forwarding `opts.bucket` to the right bucket, and wrapping rather than passing `createStorage(...).download` itself, whose second parameter is a byte range.", "", "Without it a bucket-backed `lunora backup restore --bucket` cannot read the snapshot. The object is still readable out of band with `wrangler r2 object get`."];
|
|
298
|
+
readonly status: 400;
|
|
299
|
+
readonly title: "Storage download not configured";
|
|
300
|
+
};
|
|
301
|
+
readonly STORAGE_NOT_CONFIGURED: {
|
|
302
|
+
readonly status: 400;
|
|
303
|
+
readonly title: "Storage not configured";
|
|
304
|
+
};
|
|
305
|
+
readonly STORAGE_OBJECT_NOT_FOUND: {
|
|
306
|
+
readonly status: 404;
|
|
307
|
+
readonly title: "Storage object not found";
|
|
308
|
+
};
|
|
309
|
+
readonly STORAGE_UPLOAD_NOT_CONFIGURED: {
|
|
310
|
+
readonly status: 400;
|
|
311
|
+
readonly title: "Storage upload not configured";
|
|
312
|
+
};
|
|
313
|
+
readonly STORAGE_URL_NOT_CONFIGURED: {
|
|
314
|
+
readonly status: 400;
|
|
315
|
+
readonly title: "Storage signed URL not configured";
|
|
316
|
+
};
|
|
317
|
+
readonly VECTORS_NOT_CONFIGURED: {
|
|
318
|
+
readonly status: 400;
|
|
319
|
+
readonly title: "Vector index introspector not configured";
|
|
320
|
+
};
|
|
321
|
+
readonly VECTOR_QUERY_UNSUPPORTED: {
|
|
322
|
+
readonly status: 400;
|
|
323
|
+
readonly title: "Vector index querying not enabled";
|
|
324
|
+
};
|
|
325
|
+
readonly WORKFLOWS_NOT_CONFIGURED: {
|
|
326
|
+
readonly status: 501;
|
|
327
|
+
readonly title: "Workflows not configured";
|
|
328
|
+
};
|
|
329
|
+
/** The auth/security audit read plane (`__lunora_admin__:getAuthAuditLog`). */
|
|
330
|
+
readonly AUTH_AUDIT_NOT_CONFIGURED: {
|
|
331
|
+
readonly status: 400;
|
|
332
|
+
readonly title: "Auth audit reader not configured";
|
|
333
|
+
};
|
|
334
|
+
/**
|
|
335
|
+
* Backend/DB failure reading the auth audit store. The throw site already
|
|
336
|
+
* keeps the message generic and logs the real error server-side only — flagged
|
|
337
|
+
* `internal: true` anyway as the deliberate posture for "a backend read
|
|
338
|
+
* failed", so a future edit that inlines the driver error can't leak it.
|
|
339
|
+
*/
|
|
340
|
+
readonly AUTH_AUDIT_READ_FAILED: {
|
|
341
|
+
readonly internal: true;
|
|
342
|
+
readonly status: 500;
|
|
343
|
+
readonly title: "Auth audit read failed";
|
|
344
|
+
};
|
|
345
|
+
/**
|
|
346
|
+
* Cron-job codes. The `*_NOT_STATIC` / `_INVALID` family are codegen
|
|
347
|
+
* build-time diagnostics — like `CODEGEN_DIAGNOSTIC`, they're thrown as plain
|
|
348
|
+
* messages into the CLI/Vite-overlay output, never cross the RPC wire, and are
|
|
349
|
+
* deliberately not `internal` (the message IS the fix). `CRON_JOB_FAILED` is
|
|
350
|
+
* the one runtime-reachable code in this family — its message interpolates
|
|
351
|
+
* binding/function/job names from the deployment, so it is flagged internal.
|
|
352
|
+
*/
|
|
353
|
+
readonly CRON_EXPR_INVALID: {
|
|
354
|
+
readonly status: 500;
|
|
355
|
+
readonly title: "Invalid cron expression";
|
|
356
|
+
};
|
|
357
|
+
readonly CRON_EXPR_NOT_STATIC: {
|
|
358
|
+
readonly status: 500;
|
|
359
|
+
readonly title: "Cron expression is not statically analyzable";
|
|
360
|
+
};
|
|
361
|
+
readonly CRON_JOB_FAILED: {
|
|
362
|
+
readonly internal: true;
|
|
363
|
+
readonly status: 500;
|
|
364
|
+
readonly title: "Cron job failed";
|
|
365
|
+
};
|
|
366
|
+
readonly CRON_NAME_NOT_STATIC: {
|
|
367
|
+
readonly status: 500;
|
|
368
|
+
readonly title: "Cron job name is not statically analyzable";
|
|
369
|
+
};
|
|
370
|
+
readonly CRON_NON_STATIC_FN: {
|
|
371
|
+
readonly status: 500;
|
|
372
|
+
readonly title: "Cron function reference is not statically analyzable";
|
|
373
|
+
};
|
|
374
|
+
readonly CRON_NON_STATIC_VALUE: {
|
|
375
|
+
readonly status: 500;
|
|
376
|
+
readonly title: "Cron value is not statically analyzable";
|
|
377
|
+
};
|
|
378
|
+
readonly CRON_SCHEDULE_INVALID: {
|
|
379
|
+
readonly status: 500;
|
|
380
|
+
readonly title: "Invalid cron schedule";
|
|
381
|
+
};
|
|
382
|
+
readonly CRON_SCHEDULE_NOT_STATIC: {
|
|
383
|
+
readonly status: 500;
|
|
384
|
+
readonly title: "Cron schedule is not statically analyzable";
|
|
385
|
+
};
|
|
386
|
+
readonly DUPLICATE_CRON_NAME: {
|
|
387
|
+
readonly status: 500;
|
|
388
|
+
readonly title: "Duplicate cron job name";
|
|
389
|
+
};
|
|
390
|
+
/** More codegen build-time diagnostics — see the cron-family comment above; same reasoning applies. */
|
|
391
|
+
readonly DUPLICATE_AGENT_BINDING: {
|
|
392
|
+
readonly status: 500;
|
|
393
|
+
readonly title: "Duplicate agent binding";
|
|
394
|
+
};
|
|
395
|
+
readonly DUPLICATE_AGENT_CLASS: {
|
|
396
|
+
readonly status: 500;
|
|
397
|
+
readonly title: "Duplicate agent generated class name";
|
|
398
|
+
};
|
|
399
|
+
readonly DUPLICATE_AGENT_NAME: {
|
|
400
|
+
readonly status: 500;
|
|
401
|
+
readonly title: "Duplicate agent name";
|
|
402
|
+
};
|
|
403
|
+
readonly DUPLICATE_MIGRATION_ID: {
|
|
404
|
+
readonly status: 500;
|
|
405
|
+
readonly title: "Duplicate migration id";
|
|
406
|
+
};
|
|
407
|
+
readonly DUPLICATE_QUEUE_BINDING: {
|
|
408
|
+
readonly status: 500;
|
|
409
|
+
readonly title: "Duplicate queue binding";
|
|
410
|
+
};
|
|
411
|
+
readonly DUPLICATE_QUEUE_NAME: {
|
|
412
|
+
readonly status: 500;
|
|
413
|
+
readonly title: "Duplicate queue name";
|
|
414
|
+
};
|
|
415
|
+
readonly DUPLICATE_WORKFLOW_CLASS: {
|
|
416
|
+
readonly status: 500;
|
|
417
|
+
readonly title: "Duplicate workflow generated class name";
|
|
418
|
+
};
|
|
419
|
+
readonly MIGRATION_ID_NOT_STATIC: {
|
|
420
|
+
readonly status: 500;
|
|
421
|
+
readonly title: "Migration id is not statically analyzable";
|
|
422
|
+
};
|
|
423
|
+
readonly NAMESPACE_COLLISION: {
|
|
424
|
+
readonly status: 500;
|
|
425
|
+
readonly title: "Function namespace collision";
|
|
426
|
+
};
|
|
427
|
+
/**
|
|
428
|
+
* `@lunora/runtime`'s dispatch/security-boundary codes — RPC/HTTP entry, not
|
|
429
|
+
* admin-gated. Fixed, non-sensitive messages throughout, so none are `internal`.
|
|
430
|
+
*/
|
|
431
|
+
readonly BAD_ROW: {
|
|
432
|
+
readonly status: 400;
|
|
433
|
+
readonly title: "Malformed import row";
|
|
434
|
+
};
|
|
435
|
+
readonly BAD_SUBSCRIPTION_ARGS: {
|
|
436
|
+
readonly status: 400;
|
|
437
|
+
readonly title: "Invalid subscription arguments";
|
|
438
|
+
};
|
|
439
|
+
readonly BATCH_LIMIT_EXCEEDED: {
|
|
440
|
+
readonly status: 400;
|
|
441
|
+
readonly title: "Batch limit exceeded";
|
|
442
|
+
};
|
|
443
|
+
readonly CROSS_SHARD_RANK_UNSUPPORTED: {
|
|
444
|
+
readonly status: 400;
|
|
445
|
+
readonly title: "Cross-shard rank() is unsupported";
|
|
446
|
+
};
|
|
447
|
+
readonly FORBIDDEN_FANOUT: {
|
|
448
|
+
readonly status: 403;
|
|
449
|
+
readonly title: "Fan-out forbidden";
|
|
450
|
+
};
|
|
451
|
+
readonly FORBIDDEN_ORIGIN: {
|
|
452
|
+
readonly status: 403;
|
|
453
|
+
readonly title: "Origin forbidden";
|
|
454
|
+
};
|
|
455
|
+
readonly FORBIDDEN_SHARD: {
|
|
456
|
+
readonly status: 403;
|
|
457
|
+
readonly title: "Shard access forbidden";
|
|
458
|
+
};
|
|
459
|
+
readonly GLOBAL_NOT_CONFIGURED: {
|
|
460
|
+
readonly status: 400;
|
|
461
|
+
readonly title: "Global table import not configured";
|
|
462
|
+
};
|
|
463
|
+
readonly INVALID_INPUT: {
|
|
464
|
+
readonly status: 400;
|
|
465
|
+
readonly title: "Invalid input";
|
|
466
|
+
};
|
|
467
|
+
readonly RATE_LIMITED: {
|
|
468
|
+
readonly status: 429;
|
|
469
|
+
readonly title: "Rate limited";
|
|
470
|
+
};
|
|
471
|
+
/**
|
|
472
|
+
* A read replica could not answer at the freshness the caller required. `421`
|
|
473
|
+
* rather than an error class: it is a ROUTING verdict the runtime turns into
|
|
474
|
+
* one retry against the owner, and a caller never sees it.
|
|
475
|
+
*/
|
|
476
|
+
readonly REPLICA_NOT_READY: {
|
|
477
|
+
readonly status: 421;
|
|
478
|
+
readonly title: "Replica not caught up";
|
|
479
|
+
};
|
|
480
|
+
/** A write reached a read replica. Same `421` routing verdict — writes belong to the owner. */
|
|
481
|
+
readonly REPLICA_READ_ONLY: {
|
|
482
|
+
readonly status: 421;
|
|
483
|
+
readonly title: "Replica is read-only";
|
|
484
|
+
};
|
|
485
|
+
/** Thrown by `@lunora/auth` (Turnstile) and `@lunora/ratelimit` — an upstream dependency didn't respond. Fixed, safe message. */
|
|
486
|
+
readonly SERVICE_UNAVAILABLE: {
|
|
487
|
+
readonly status: 503;
|
|
488
|
+
readonly title: "Service unavailable";
|
|
489
|
+
};
|
|
490
|
+
readonly SHAPE_CROSS_SHARD_JOIN: {
|
|
491
|
+
readonly status: 400;
|
|
492
|
+
readonly title: "Shape cross-shard join is unsupported";
|
|
493
|
+
};
|
|
494
|
+
readonly UNAUTHENTICATED: {
|
|
495
|
+
readonly status: 401;
|
|
496
|
+
readonly title: "Unauthenticated";
|
|
497
|
+
};
|
|
498
|
+
readonly UNKNOWN_COLUMN: {
|
|
499
|
+
readonly status: 404;
|
|
500
|
+
readonly title: "Unknown column";
|
|
501
|
+
};
|
|
502
|
+
/**
|
|
503
|
+
* `@lunora/do`'s ShardDO — WebSocket-frame codes and SQLite-in-DO invariants.
|
|
504
|
+
* `NESTED_TRANSACTION` and `SQL_UNAVAILABLE` are "should never happen" state
|
|
505
|
+
* invariants (mirrors `RUN_DEPTH_EXCEEDED`'s posture above): today's message
|
|
506
|
+
* is static and safe, but flagged internal so a future edit that adds
|
|
507
|
+
* diagnostic detail can't accidentally start leaking it.
|
|
508
|
+
*/
|
|
509
|
+
readonly EXPIRED: {
|
|
510
|
+
readonly status: 404;
|
|
511
|
+
readonly title: "Session expired";
|
|
512
|
+
};
|
|
513
|
+
readonly NESTED_TRANSACTION: {
|
|
514
|
+
readonly internal: true;
|
|
515
|
+
readonly status: 500;
|
|
516
|
+
readonly title: "Nested transaction";
|
|
517
|
+
};
|
|
518
|
+
readonly OUT_OF_ORDER: {
|
|
519
|
+
readonly status: 409;
|
|
520
|
+
readonly title: "Out-of-order mutation";
|
|
521
|
+
};
|
|
522
|
+
readonly SHAPE_GLOBAL_TOO_LARGE: {
|
|
523
|
+
readonly status: 413;
|
|
524
|
+
readonly title: "Global shape too large";
|
|
525
|
+
};
|
|
526
|
+
readonly SHAPE_NOT_FOUND: {
|
|
527
|
+
readonly status: 404;
|
|
528
|
+
readonly title: "Shape not found";
|
|
529
|
+
};
|
|
530
|
+
readonly SQL_UNAVAILABLE: {
|
|
531
|
+
readonly internal: true;
|
|
532
|
+
readonly status: 500;
|
|
533
|
+
readonly title: "SQL storage unavailable";
|
|
534
|
+
};
|
|
535
|
+
readonly TOKEN_EXPIRED: {
|
|
536
|
+
readonly status: 401;
|
|
537
|
+
readonly title: "Authentication token expired";
|
|
538
|
+
};
|
|
539
|
+
readonly TOO_MANY_STREAMS: {
|
|
540
|
+
readonly status: 429;
|
|
541
|
+
readonly title: "Too many streams";
|
|
542
|
+
};
|
|
543
|
+
readonly UNKNOWN_ADMIN_OP: {
|
|
544
|
+
readonly status: 404;
|
|
545
|
+
readonly title: "Unknown admin operation";
|
|
546
|
+
};
|
|
547
|
+
/**
|
|
548
|
+
* `@lunora/platform-cloudflare`'s `SocketHost.accept` guard — a caller
|
|
549
|
+
* supplied more accept-time tags (or a longer tag) than Cloudflare's
|
|
550
|
+
* `acceptWebSocket` budget allows once the host's own identity tag is
|
|
551
|
+
* reserved. Caller-actionable and safe (names counts, not internals) —
|
|
552
|
+
* not `internal`.
|
|
553
|
+
*/
|
|
554
|
+
readonly SOCKET_TAG_BUDGET_EXCEEDED: {
|
|
555
|
+
readonly status: 400;
|
|
556
|
+
readonly title: "Socket tag budget exceeded";
|
|
557
|
+
};
|
|
558
|
+
/**
|
|
559
|
+
* `@lunora/shard-engine`'s relay hub (cross-shard shape relay coordination).
|
|
560
|
+
* Mirrors `SHARD_ERROR`/`SHARD_UNAVAILABLE` above: operational status for an
|
|
561
|
+
* app's own relay topology, not a secret — not `internal`.
|
|
562
|
+
*/
|
|
563
|
+
readonly RELAY_CANNOT_SEED: {
|
|
564
|
+
readonly status: 500;
|
|
565
|
+
readonly title: "Relay cannot seed";
|
|
566
|
+
};
|
|
567
|
+
readonly RELAY_MISCONFIGURED: {
|
|
568
|
+
readonly status: 500;
|
|
569
|
+
readonly title: "Relay misconfigured";
|
|
570
|
+
};
|
|
571
|
+
readonly RELAY_SEED_FAILED: {
|
|
572
|
+
readonly status: 502;
|
|
573
|
+
readonly title: "Relay seed failed";
|
|
574
|
+
};
|
|
575
|
+
/**
|
|
576
|
+
* A worker option required by the request path is absent (a deploy-config
|
|
577
|
+
* gap, not a caller error) — the fixed message names the missing option, so
|
|
578
|
+
* it's actionable and echoed. `MISCONFIGURED` is the one exception: its
|
|
579
|
+
* message interpolates the caller-supplied `functionPath`, and it's the code
|
|
580
|
+
* this plan's audit found live-leaking (`create-worker.ts`'s x402 gate).
|
|
581
|
+
*/
|
|
582
|
+
readonly MISCONFIGURED: {
|
|
583
|
+
readonly internal: true;
|
|
584
|
+
readonly status: 500;
|
|
585
|
+
readonly title: "Worker misconfigured";
|
|
586
|
+
};
|
|
587
|
+
/** `@lunora/nuxt`'s Nitro bridge: the request carried no Cloudflare bindings. Fixed, safe message. */
|
|
588
|
+
readonly LUNORA_RUNTIME_UNAVAILABLE: {
|
|
589
|
+
readonly status: 500;
|
|
590
|
+
readonly title: "Lunora runtime unavailable";
|
|
591
|
+
};
|
|
592
|
+
/**
|
|
593
|
+
* `@lunora/replica`'s event-log Durable Object: generic request-handler
|
|
594
|
+
* catch-all, mirroring `INTERNAL`/`INTERNAL_SERVER_ERROR`/`RPC_FAILED` above
|
|
595
|
+
* — the real error is logged server-side only, never in this code's message.
|
|
596
|
+
*/
|
|
597
|
+
readonly INTERNAL_ERROR: {
|
|
598
|
+
readonly internal: true;
|
|
599
|
+
readonly status: 500;
|
|
600
|
+
readonly title: "Internal error";
|
|
601
|
+
};
|
|
602
|
+
/**
|
|
603
|
+
* Client-SDK-only codes (`@lunora/client`), thrown locally in the browser/app
|
|
604
|
+
* process rather than by the server — `internal`'s wire-redaction semantics
|
|
605
|
+
* don't apply the same way here, since the "wire" is the app's own code
|
|
606
|
+
* catching its own client's exception. Kept in the catalog for the client's
|
|
607
|
+
* `code`-discrimination union and Studio/CLI rendering consistency.
|
|
608
|
+
*/
|
|
609
|
+
readonly BROWSER_TIMEOUT: {
|
|
610
|
+
readonly status: 504;
|
|
611
|
+
readonly title: "Browser operation timed out";
|
|
612
|
+
};
|
|
613
|
+
readonly CLIENT_CLOSED: {
|
|
614
|
+
readonly status: 400;
|
|
615
|
+
readonly title: "Client is closed";
|
|
616
|
+
};
|
|
617
|
+
readonly HTTP_STREAM_BAD_CHUNK: {
|
|
618
|
+
readonly status: 502;
|
|
619
|
+
readonly title: "Malformed HTTP stream chunk";
|
|
620
|
+
};
|
|
621
|
+
readonly HTTP_STREAM_INTERRUPTED: {
|
|
622
|
+
readonly status: 502;
|
|
623
|
+
readonly title: "HTTP stream interrupted";
|
|
624
|
+
};
|
|
625
|
+
readonly HTTP_STREAM_MISSING_PARAM: {
|
|
626
|
+
readonly status: 400;
|
|
627
|
+
readonly title: "HTTP stream missing path parameter";
|
|
628
|
+
};
|
|
629
|
+
readonly HTTP_STREAM_NO_BODY: {
|
|
630
|
+
readonly status: 502;
|
|
631
|
+
readonly title: "HTTP stream response has no body";
|
|
632
|
+
};
|
|
633
|
+
readonly HTTP_STREAM_STATUS: {
|
|
634
|
+
readonly status: 502;
|
|
635
|
+
readonly title: "HTTP stream request failed";
|
|
636
|
+
};
|
|
637
|
+
readonly HTTP_STREAM_TRANSPORT: {
|
|
638
|
+
readonly status: 502;
|
|
639
|
+
readonly title: "HTTP stream transport error";
|
|
640
|
+
};
|
|
641
|
+
readonly STREAM_BACKPRESSURE: {
|
|
642
|
+
readonly status: 429;
|
|
643
|
+
readonly title: "Stream backpressure";
|
|
644
|
+
};
|
|
645
|
+
readonly STREAM_DISCONNECTED: {
|
|
646
|
+
readonly status: 503;
|
|
647
|
+
readonly title: "Stream disconnected";
|
|
648
|
+
};
|
|
649
|
+
readonly STREAM_QUEUE_OVERFLOW: {
|
|
650
|
+
readonly status: 429;
|
|
651
|
+
readonly title: "Stream queue overflow";
|
|
652
|
+
};
|
|
653
|
+
/** `@lunora/db`'s offline outbox: a queued write targeted a collection removed/renamed in a later deploy. */
|
|
654
|
+
readonly UNKNOWN_MUTATION_FN: {
|
|
655
|
+
readonly status: 404;
|
|
656
|
+
readonly title: "Unknown mutation function";
|
|
657
|
+
};
|
|
179
658
|
};
|
|
180
659
|
/** A well-known Lunora error code (a key of {@link ERROR_CATALOG}). */
|
|
181
660
|
type LunoraErrorCode = keyof typeof ERROR_CATALOG;
|
|
182
661
|
/**
|
|
183
|
-
* True when `code` is an internal/redacted code — an internal failure or
|
|
184
|
-
* unhandled invariant whose `message` must NOT cross the wire (it may carry SQL
|
|
185
|
-
* fragments, file paths, or internal identifiers). Derived from the catalog's
|
|
186
|
-
* `internal` flag so the redaction posture stays in one place (the table).
|
|
187
|
-
* Throwing a `LunoraError` with any non-internal code is the author's vouch that
|
|
188
|
-
* its message is client-safe; an unknown/unregistered code is treated as safe.
|
|
189
|
-
*/
|
|
662
|
+
* True when `code` is an internal/redacted code — an internal failure or
|
|
663
|
+
* unhandled invariant whose `message` must NOT cross the wire (it may carry SQL
|
|
664
|
+
* fragments, file paths, or internal identifiers). Derived from the catalog's
|
|
665
|
+
* `internal` flag so the redaction posture stays in one place (the table).
|
|
666
|
+
* Throwing a `LunoraError` with any non-internal code is the author's vouch that
|
|
667
|
+
* its message is client-safe; an unknown/unregistered code is treated as safe.
|
|
668
|
+
*/
|
|
190
669
|
declare const isInternalCode: (code: string) => boolean;
|
|
191
670
|
/**
|
|
192
|
-
* A message-matched solution for errors that reach a consumer without a `code`
|
|
193
|
-
* — chiefly `@lunora/codegen` build errors, which are thrown as plain messages
|
|
194
|
-
* into generated code (and flattened to `{ message }` by the Vite overlay), so
|
|
195
|
-
* the message text is the only stable join key. Ordered most- to least-specific;
|
|
196
|
-
* the first matching rule wins.
|
|
197
|
-
*/
|
|
671
|
+
* A message-matched solution for errors that reach a consumer without a `code`
|
|
672
|
+
* — chiefly `@lunora/codegen` build errors, which are thrown as plain messages
|
|
673
|
+
* into generated code (and flattened to `{ message }` by the Vite overlay), so
|
|
674
|
+
* the message text is the only stable join key. Ordered most- to least-specific;
|
|
675
|
+
* the first matching rule wins.
|
|
676
|
+
*/
|
|
198
677
|
interface Solution {
|
|
199
678
|
/** Markdown body shown under the header. */
|
|
200
679
|
body: string;
|
|
@@ -209,27 +688,92 @@ interface SolutionRule extends Solution {
|
|
|
209
688
|
test: (message: string) => boolean;
|
|
210
689
|
}
|
|
211
690
|
/**
|
|
212
|
-
* Message-matched solutions (migrated verbatim from the former
|
|
213
|
-
* `@lunora/codegen` solutions table). Re-exported by `@lunora/codegen` as
|
|
214
|
-
* `LUNORA_SOLUTION_RULES` for backward compatibility.
|
|
215
|
-
*/
|
|
691
|
+
* Message-matched solutions (migrated verbatim from the former
|
|
692
|
+
* `@lunora/codegen` solutions table). Re-exported by `@lunora/codegen` as
|
|
693
|
+
* `LUNORA_SOLUTION_RULES` for backward compatibility.
|
|
694
|
+
*/
|
|
216
695
|
declare const MESSAGE_SOLUTIONS: ReadonlyArray<SolutionRule>;
|
|
217
696
|
/**
|
|
218
|
-
*
|
|
219
|
-
*
|
|
220
|
-
*
|
|
221
|
-
|
|
697
|
+
* One documented Cloudflare **platform** error — an edge/origin (5xx) or
|
|
698
|
+
* Cloudflare-service (1xxx) failure surfaced in an error *message* rather than
|
|
699
|
+
* thrown by Lunora as a coded `LunoraError`. These reach a Lunora app as
|
|
700
|
+
* plain text: a Worker that fetches a Cloudflare-fronted origin sees `Error 522`,
|
|
701
|
+
* a deploy that throws surfaces as `Error 1101`, and so on. The fields are the
|
|
702
|
+
* curated facts a grounded explainer elaborates on — never invents beyond.
|
|
703
|
+
*/
|
|
704
|
+
interface CloudflarePlatformError {
|
|
705
|
+
/** Documented likely causes (a short, comma-joined clause). */
|
|
706
|
+
causes: string;
|
|
707
|
+
/** The numeric Cloudflare error code, as it appears in the message (e.g. `"522"`, `"1101"`). */
|
|
708
|
+
code: string;
|
|
709
|
+
/** Canonical Cloudflare support-docs URL for this error's family. */
|
|
710
|
+
docsUrl: string;
|
|
711
|
+
/** Which docs family the code belongs to — shown in the "see docs" line. */
|
|
712
|
+
family: "1xxx" | "5xx";
|
|
713
|
+
/** The documented remediation. */
|
|
714
|
+
fix: string;
|
|
715
|
+
/** One-line summary of what the code means. */
|
|
716
|
+
summary: string;
|
|
717
|
+
/** Cloudflare's short name for the code (e.g. `"Connection timed out"`). */
|
|
718
|
+
title: string;
|
|
719
|
+
}
|
|
720
|
+
/**
|
|
721
|
+
* The curated Cloudflare platform-error table. Sourced from Cloudflare's official
|
|
722
|
+
* support docs — the codes surfaced to app authors on Workers/DO deployments (the
|
|
723
|
+
* origin-connection 52x family and the Worker/DNS/security 1xxx family). `1101`
|
|
724
|
+
* (a Worker threw) and `1102` (a Worker exceeded CPU) are the most Lunora-relevant.
|
|
725
|
+
*/
|
|
726
|
+
declare const CLOUDFLARE_PLATFORM_ERRORS: ReadonlyArray<CloudflarePlatformError>;
|
|
727
|
+
/**
|
|
728
|
+
* Recognize a Cloudflare platform-error {@link CloudflarePlatformError} in a raw
|
|
729
|
+
* error message, conservatively: the message must carry Cloudflare's own
|
|
730
|
+
* `Error <code>` phrasing, or mention `cloudflare` alongside the standalone
|
|
731
|
+
* code. That keeps a bare number (`expected 520 items`) from false-matching a 5xx
|
|
732
|
+
* code, at the cost of missing a context-free code — the safe trade for a
|
|
733
|
+
* grounded hint. Returns the matched code's {@link Solution}, or `undefined`.
|
|
734
|
+
*
|
|
735
|
+
* Matching runs in two passes, strongest first: Cloudflare's own `Error <code>`
|
|
736
|
+
* phrasing is unambiguous, so it must win over the weaker "mentions cloudflare
|
|
737
|
+
* near some number" heuristic regardless of table order. A single pass let a weak
|
|
738
|
+
* match on an earlier entry beat an explicit match on a later one — `"Cloudflare
|
|
739
|
+
* Error 1102: exceeded after 524 ms"` resolved to 524, and that wrong grounded
|
|
740
|
+
* fix is exactly what the explainer prompt is built from.
|
|
741
|
+
*/
|
|
742
|
+
declare const findCloudflarePlatformSolution: (message: string) => Solution | undefined;
|
|
743
|
+
/**
|
|
744
|
+
* Flatten a Markdown hint to plain text for a terminal / non-Markdown surface:
|
|
745
|
+
* drop code-fence markers and strip inline `**bold**` / `` `code` `` emphasis.
|
|
746
|
+
* Shared by the CLI renderer and the Studio `ErrorAlert` so the two can't drift.
|
|
747
|
+
*/
|
|
222
748
|
declare const flattenHint: (hint: ErrorHint) => string;
|
|
223
749
|
/**
|
|
224
|
-
* Find the first message-matched {@link Solution} for `message`, or `undefined`
|
|
225
|
-
* if none recognize it. Re-exported by `@lunora/codegen` as `findLunoraSolution`.
|
|
226
|
-
*/
|
|
750
|
+
* Find the first message-matched {@link Solution} for `message`, or `undefined`
|
|
751
|
+
* if none recognize it. Re-exported by `@lunora/codegen` as `findLunoraSolution`.
|
|
752
|
+
*/
|
|
227
753
|
declare const findSolutionByMessage: (message: string) => Solution | undefined;
|
|
228
754
|
/**
|
|
229
|
-
*
|
|
230
|
-
*
|
|
231
|
-
* `
|
|
232
|
-
|
|
755
|
+
* Find a solution for `message` across BOTH Lunora's own rules and the curated
|
|
756
|
+
* Cloudflare platform-error table — the lookup the Studio Issues panel and the
|
|
757
|
+
* `explainIssue` grounding use.
|
|
758
|
+
*
|
|
759
|
+
* Deliberately separate from {@link findSolutionByMessage} rather than folded into
|
|
760
|
+
* it. That function is on `resolveHint`, and therefore on `toErrorBody` — the
|
|
761
|
+
* envelope builder for every failed request. Most `ERROR_CATALOG` entries
|
|
762
|
+
* carry no `hint`, so folding the platform table in there meant an ordinary
|
|
763
|
+
* `BAD_REQUEST` whose message merely mentioned "cloudflare" near a number shipped
|
|
764
|
+
* zone-configuration guidance ("review the zone's Firewall/WAF and IP Access
|
|
765
|
+
* Rules") to unauthenticated browsers. The same fold put the table on the CLI
|
|
766
|
+
* renderer and the Vite overlay, and on `toErrorBody`'s hot path.
|
|
767
|
+
*
|
|
768
|
+
* Platform errors are operator-facing context for an already-persisted Issue, so
|
|
769
|
+
* the operator-facing surfaces opt in here and the wire path stays Lunora-only.
|
|
770
|
+
*/
|
|
771
|
+
declare const findIssueSolution: (message: string) => Solution | undefined;
|
|
772
|
+
/**
|
|
773
|
+
* Resolve an actionable hint for an error: prefer a hint carried on the error
|
|
774
|
+
* (or its `code`'s catalog entry), then fall back to a message match. Returns
|
|
775
|
+
* `undefined` when nothing recognizes it.
|
|
776
|
+
*/
|
|
233
777
|
declare const resolveHint: (input: {
|
|
234
778
|
code?: string;
|
|
235
779
|
hint?: ErrorHint;
|
|
@@ -261,16 +805,16 @@ interface LunoraErrorOptions {
|
|
|
261
805
|
title?: string;
|
|
262
806
|
}
|
|
263
807
|
/**
|
|
264
|
-
* A code string: a well-known {@link LunoraErrorCode} (with autocomplete) or any
|
|
265
|
-
* package-specific code not yet in the catalog.
|
|
266
|
-
*/
|
|
808
|
+
* A code string: a well-known {@link LunoraErrorCode} (with autocomplete) or any
|
|
809
|
+
* package-specific code not yet in the catalog.
|
|
810
|
+
*/
|
|
267
811
|
type LunoraErrorCodeInput = LunoraErrorCode | (string & {});
|
|
268
812
|
declare class LunoraError extends Error {
|
|
269
813
|
/**
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
814
|
+
* Discriminator recognised by `@visulima/error`'s `renderError`/`isVisulimaError`
|
|
815
|
+
* (`error.type === "VisulimaError"`), so a `LunoraError` renders like a native
|
|
816
|
+
* `VisulimaError` — hint and all.
|
|
817
|
+
*/
|
|
274
818
|
readonly type = "VisulimaError";
|
|
275
819
|
/** Actionable fix (Markdown), rendered by the CLI/overlay/Studio. */
|
|
276
820
|
readonly hint: ErrorHint | undefined;
|
|
@@ -278,7 +822,7 @@ declare class LunoraError extends Error {
|
|
|
278
822
|
readonly title: string | undefined;
|
|
279
823
|
/** Source location, when known (mirrors `VisulimaError.loc`). */
|
|
280
824
|
readonly loc: ErrorLocation | undefined;
|
|
281
|
-
/** Machine-readable reason, keyed into
|
|
825
|
+
/** Machine-readable reason, keyed into `ERROR_CATALOG`. */
|
|
282
826
|
readonly code: string;
|
|
283
827
|
/** HTTP/RPC status for the transport mappers. */
|
|
284
828
|
readonly status: number;
|
|
@@ -295,8 +839,15 @@ interface LunoraErrorLike extends Error {
|
|
|
295
839
|
docsUrl?: string;
|
|
296
840
|
hint?: ErrorHint;
|
|
297
841
|
status: number;
|
|
842
|
+
/** Wire brand that distinguishes real `LunoraError`s from foreign errors. */
|
|
843
|
+
type: "VisulimaError";
|
|
298
844
|
}
|
|
299
|
-
/**
|
|
845
|
+
/**
|
|
846
|
+
* True when `error` carries the Lunora transport shape (string `code` + numeric
|
|
847
|
+
* `status` + the `VisulimaError` brand). The `type` brand is what distinguishes
|
|
848
|
+
* a real `LunoraError` (or its wire-decoded twin) from a foreign error that
|
|
849
|
+
* happens to carry `code`/`status` — see plan 119 for the full rationale.
|
|
850
|
+
*/
|
|
300
851
|
declare const isLunoraError: (error: unknown) => error is LunoraErrorLike;
|
|
301
852
|
/** Throw an `INTERNAL` {@link LunoraError} when `condition` is falsy. */
|
|
302
853
|
declare const invariant: (condition: unknown, message: string) => asserts condition;
|
|
@@ -312,9 +863,9 @@ interface ErrorBody {
|
|
|
312
863
|
}
|
|
313
864
|
interface ToErrorBodyOptions {
|
|
314
865
|
/**
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
866
|
+
* Wire-encode a `LunoraError`'s structured `data` for the client (so a
|
|
867
|
+
* `bigint`/`bytes` inside it survives). Omit to drop `data` from the body.
|
|
868
|
+
*/
|
|
318
869
|
encodeData?: (data: unknown) => unknown;
|
|
319
870
|
/** Code for an unrecognized (non-`LunoraError`) throw. Default `"INTERNAL"`. */
|
|
320
871
|
fallbackCode?: string;
|
|
@@ -329,12 +880,12 @@ interface ToErrorBodyResult {
|
|
|
329
880
|
status: number;
|
|
330
881
|
}
|
|
331
882
|
/**
|
|
332
|
-
* Turn a thrown value into an {@link ErrorBody} + status, applying the redaction
|
|
333
|
-
* invariant. A `LunoraError` with a non-internal code is echoed with its
|
|
334
|
-
* `message`, resolved `hint`, `docsUrl`, and (when `encodeData` is given) its
|
|
335
|
-
* `data`. An internal-coded `LunoraError` keeps its `code`/`status` but its
|
|
336
|
-
* message is replaced with `redactedMessage`. Anything else becomes a generic
|
|
337
|
-
* `fallbackCode`/500. When `redacted` is `true`, log the raw error server-side.
|
|
338
|
-
*/
|
|
883
|
+
* Turn a thrown value into an {@link ErrorBody} + status, applying the redaction
|
|
884
|
+
* invariant. A `LunoraError` with a non-internal code is echoed with its
|
|
885
|
+
* `message`, resolved `hint`, `docsUrl`, and (when `encodeData` is given) its
|
|
886
|
+
* `data`. An internal-coded `LunoraError` keeps its `code`/`status` but its
|
|
887
|
+
* message is replaced with `redactedMessage`. Anything else becomes a generic
|
|
888
|
+
* `fallbackCode`/500. When `redacted` is `true`, log the raw error server-side.
|
|
889
|
+
*/
|
|
339
890
|
declare const toErrorBody: (error: unknown, options?: ToErrorBodyOptions) => ToErrorBodyResult;
|
|
340
|
-
export { ERROR_CATALOG, type ErrorBody, type ErrorCatalogEntry, type ErrorHint, type ErrorLocation, LunoraError, type LunoraErrorCode, type LunoraErrorCodeInput, type LunoraErrorLike, type LunoraErrorOptions, MESSAGE_SOLUTIONS, type Solution, type SolutionRule, type ToErrorBodyOptions, type ToErrorBodyResult, findSolutionByMessage, flattenHint, invariant, isInternalCode, isLunoraError, resolveHint, toErrorBody, unreachable };
|
|
891
|
+
export { CLOUDFLARE_PLATFORM_ERRORS, type CloudflarePlatformError, ERROR_CATALOG, type ErrorBody, type ErrorCatalogEntry, type ErrorHint, type ErrorLocation, LunoraError, type LunoraErrorCode, type LunoraErrorCodeInput, type LunoraErrorLike, type LunoraErrorOptions, MESSAGE_SOLUTIONS, type Solution, type SolutionRule, type ToErrorBodyOptions, type ToErrorBodyResult, findCloudflarePlatformSolution, findIssueSolution, findSolutionByMessage, flattenHint, invariant, isInternalCode, isLunoraError, resolveHint, toErrorBody, unreachable };
|