/**
* Nexus Error Boundaries — file-based resilience system.
*
* Convention (mirrors Next.js App Router):
*
* routes/
* ├── error.nx ← catches errors in the root layout
* ├── dashboard/
* │ ├── error.nx ← catches errors in /dashboard/**
* │ ├── +layout.nx
* │ └── +page.nx
* └── blog/
* ├── [slug]/
* │ ├── error.nx ← catches errors ONLY in /blog/:slug
* │ └── +page.nx
* └── not-found.nx ← custom 404 for /blog/**
*
* The error.nx component receives:
* - error: { message, name, digest? }
* - reset: () => void (client-side — triggers re-render)
*
* Island hydration for error.nx:
* The "reset" button must be an island (client:load) to be interactive.
* The error info is server-rendered (no JS needed to display it).
*
* Usage in error.nx:
* ---
* const { error } = ctx.errorBoundary;
* ---
*
*
*
Something went wrong
*
{error.message}
*
*
*/
import type { NexusContext } from './context.js';
export interface BoundaryError {
message: string;
name: string;
/** Opaque server-side error digest (safe to show in prod) */
digest?: string;
/** Full stack trace (dev only) */
stack?: string;
}
export interface ErrorBoundaryContext {
error: BoundaryError;
pathname: string;
}
/**
* Finds the nearest `error.nx` file to a given route filepath.
* Walks up the directory tree until it finds one or reaches the routes root.
*/
export declare function findErrorBoundary(routeFilepath: string, routesRoot: string): Promise;
/**
* Finds the nearest `not-found.nx` for a given route directory.
*/
export declare function findNotFoundBoundary(routeFilepath: string, routesRoot: string): Promise;
/**
* Renders an error boundary file to HTML.
* Sanitizes error info for production (hides stack, generates digest).
*/
export declare function renderErrorBoundary(boundaryFile: string, originalError: unknown, ctx: NexusContext, opts: {
dev: boolean;
}): Promise;
/**
* Default error page when no error.nx is found.
* Shows full details in dev, sanitized message in production.
*/
export declare function buildDefaultErrorHTML(error: BoundaryError, dev: boolean): string;
/**
* Wraps a render function with error boundary protection.
* If the render throws, catches it and renders the nearest error.nx.
*/
export declare function withErrorBoundary(fn: () => Promise, opts: {
routeFilepath: string;
routesRoot: string;
ctx: NexusContext;
dev: boolean;
fallback?: string;
}): Promise;
//# sourceMappingURL=error-boundary.d.ts.map