@lunora/errors 1.0.0-alpha.23 → 1.0.0-alpha.24
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
CHANGED
|
@@ -884,6 +884,27 @@ declare const isLunoraError: (error: unknown) => error is LunoraErrorLike;
|
|
|
884
884
|
declare const invariant: (condition: unknown, message: string) => asserts condition;
|
|
885
885
|
/** Throw an `INTERNAL` {@link LunoraError} for an unreachable branch. */
|
|
886
886
|
declare const unreachable: (message: string) => never;
|
|
887
|
+
/**
|
|
888
|
+
* Throw a {@link LunoraError} from expression position.
|
|
889
|
+
*
|
|
890
|
+
* `throw` is a statement, so it cannot sit on the right of `??` or in a ternary
|
|
891
|
+
* arm — the two places a missing value is most naturally rejected. Unlike
|
|
892
|
+
* {@link invariant} and {@link unreachable}, which are pinned to `INTERNAL`, this
|
|
893
|
+
* takes the code, which is what a client-actionable failure needs.
|
|
894
|
+
*
|
|
895
|
+
* Any string is a valid `code`. A well-known `ERROR_CATALOG` key fills in the
|
|
896
|
+
* status, title and hint; a package-specific code with no catalog entry defaults
|
|
897
|
+
* to status 500 and no hint, so pass those in `options` instead.
|
|
898
|
+
* @param code machine-readable reason
|
|
899
|
+
* @param message human-readable detail; defaults to `code`
|
|
900
|
+
* @param options status/title/hint/data overrides
|
|
901
|
+
* @example
|
|
902
|
+
* ```ts
|
|
903
|
+
* const thread = (await ctx.db.threads.get(id)) ?? raise("NOT_FOUND", `thread ${id}`);
|
|
904
|
+
* // thread is non-nullable here
|
|
905
|
+
* ```
|
|
906
|
+
*/
|
|
907
|
+
declare const raise: (code: LunoraErrorCodeInput, message?: string, options?: LunoraErrorOptions) => never;
|
|
887
908
|
/** The client-facing error envelope body. */
|
|
888
909
|
interface ErrorBody {
|
|
889
910
|
code: string;
|
|
@@ -949,4 +970,4 @@ type LunoraErrorCodeInput, type LunoraErrorLike,
|
|
|
949
970
|
* renderer (`renderLunoraError`, using `@visulima/error`'s `renderError`) lives
|
|
950
971
|
* in `@lunora/cli`, which already depends on `@visulima/error`.
|
|
951
972
|
*/
|
|
952
|
-
type LunoraErrorOptions, MESSAGE_SOLUTIONS, type Solution, type SolutionRule, type ToErrorBodyOptions, type ToErrorBodyResult, findCloudflarePlatformSolution, findIssueSolution, findSolutionByMessage, flattenHint, invariant, isInternalCode, isLunoraError, resolveHint, toErrorBody, unreachable };
|
|
973
|
+
type LunoraErrorOptions, MESSAGE_SOLUTIONS, type Solution, type SolutionRule, type ToErrorBodyOptions, type ToErrorBodyResult, findCloudflarePlatformSolution, findIssueSolution, findSolutionByMessage, flattenHint, invariant, isInternalCode, isLunoraError, raise, resolveHint, toErrorBody, unreachable };
|
package/dist/index.d.ts
CHANGED
|
@@ -884,6 +884,27 @@ declare const isLunoraError: (error: unknown) => error is LunoraErrorLike;
|
|
|
884
884
|
declare const invariant: (condition: unknown, message: string) => asserts condition;
|
|
885
885
|
/** Throw an `INTERNAL` {@link LunoraError} for an unreachable branch. */
|
|
886
886
|
declare const unreachable: (message: string) => never;
|
|
887
|
+
/**
|
|
888
|
+
* Throw a {@link LunoraError} from expression position.
|
|
889
|
+
*
|
|
890
|
+
* `throw` is a statement, so it cannot sit on the right of `??` or in a ternary
|
|
891
|
+
* arm — the two places a missing value is most naturally rejected. Unlike
|
|
892
|
+
* {@link invariant} and {@link unreachable}, which are pinned to `INTERNAL`, this
|
|
893
|
+
* takes the code, which is what a client-actionable failure needs.
|
|
894
|
+
*
|
|
895
|
+
* Any string is a valid `code`. A well-known `ERROR_CATALOG` key fills in the
|
|
896
|
+
* status, title and hint; a package-specific code with no catalog entry defaults
|
|
897
|
+
* to status 500 and no hint, so pass those in `options` instead.
|
|
898
|
+
* @param code machine-readable reason
|
|
899
|
+
* @param message human-readable detail; defaults to `code`
|
|
900
|
+
* @param options status/title/hint/data overrides
|
|
901
|
+
* @example
|
|
902
|
+
* ```ts
|
|
903
|
+
* const thread = (await ctx.db.threads.get(id)) ?? raise("NOT_FOUND", `thread ${id}`);
|
|
904
|
+
* // thread is non-nullable here
|
|
905
|
+
* ```
|
|
906
|
+
*/
|
|
907
|
+
declare const raise: (code: LunoraErrorCodeInput, message?: string, options?: LunoraErrorOptions) => never;
|
|
887
908
|
/** The client-facing error envelope body. */
|
|
888
909
|
interface ErrorBody {
|
|
889
910
|
code: string;
|
|
@@ -949,4 +970,4 @@ type LunoraErrorCodeInput, type LunoraErrorLike,
|
|
|
949
970
|
* renderer (`renderLunoraError`, using `@visulima/error`'s `renderError`) lives
|
|
950
971
|
* in `@lunora/cli`, which already depends on `@visulima/error`.
|
|
951
972
|
*/
|
|
952
|
-
type LunoraErrorOptions, MESSAGE_SOLUTIONS, type Solution, type SolutionRule, type ToErrorBodyOptions, type ToErrorBodyResult, findCloudflarePlatformSolution, findIssueSolution, findSolutionByMessage, flattenHint, invariant, isInternalCode, isLunoraError, resolveHint, toErrorBody, unreachable };
|
|
973
|
+
type LunoraErrorOptions, MESSAGE_SOLUTIONS, type Solution, type SolutionRule, type ToErrorBodyOptions, type ToErrorBodyResult, findCloudflarePlatformSolution, findIssueSolution, findSolutionByMessage, flattenHint, invariant, isInternalCode, isLunoraError, raise, resolveHint, toErrorBody, unreachable };
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{LunoraError as e}from"./packem_shared/LunoraError-CR7IPzzZ.mjs";import{CLOUDFLARE_PLATFORM_ERRORS as t,ERROR_CATALOG as i,MESSAGE_SOLUTIONS as a,findCloudflarePlatformSolution as f,findIssueSolution as l,findSolutionByMessage as
|
|
1
|
+
import{LunoraError as e}from"./packem_shared/LunoraError-CR7IPzzZ.mjs";import{CLOUDFLARE_PLATFORM_ERRORS as t,ERROR_CATALOG as i,MESSAGE_SOLUTIONS as a,findCloudflarePlatformSolution as f,findIssueSolution as l,findSolutionByMessage as s,flattenHint as u,isInternalCode as E,resolveHint as R}from"./packem_shared/CLOUDFLARE_PLATFORM_ERRORS-B4sZMTxz.mjs";import{isLunoraError as L}from"./packem_shared/isLunoraError-kpNg-Mxd.mjs";import{invariant as d,raise as m,unreachable as p}from"./packem_shared/invariant-9lKACd-S.mjs";import{toErrorBody as A}from"./packem_shared/toErrorBody-yckaoqWe.mjs";export{t as CLOUDFLARE_PLATFORM_ERRORS,i as ERROR_CATALOG,e as LunoraError,a as MESSAGE_SOLUTIONS,f as findCloudflarePlatformSolution,l as findIssueSolution,s as findSolutionByMessage,u as flattenHint,d as invariant,E as isInternalCode,L as isLunoraError,m as raise,R as resolveHint,A as toErrorBody,p as unreachable};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{LunoraError as o}from"./LunoraError-CR7IPzzZ.mjs";const e=(r,n)=>{if(!r)throw new o("INTERNAL",n,{name:"InvariantError"})},i=r=>{throw new o("INTERNAL",r,{name:"InvariantError"})},w=(r,n,a)=>{throw new o(r,n,a)};export{e as invariant,w as raise,i as unreachable};
|
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.24",
|
|
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",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{LunoraError as n}from"./LunoraError-CR7IPzzZ.mjs";const t=(r,a)=>{if(!r)throw new n("INTERNAL",a,{name:"InvariantError"})},e=r=>{throw new n("INTERNAL",r,{name:"InvariantError"})};export{t as invariant,e as unreachable};
|