import { Cause } from "effect"; /** * Why a remote failure reached the client without its original detail. * * @example * ```ts * const reason: OpaqueRemoteFailureReason = "untagged"; * ``` * * @since 4.2.0 */ export type OpaqueRemoteFailureReason = "untagged" | "unserializable" | "unknown" | "interrupted"; /** * Request detail attached to an opaque remote failure report so the log line * points at the handler that produced it. * * @example * ```ts * const context: RemoteFailureContext = { method: "POST", url: "/checkout" }; * ``` * * @since 4.2.0 */ export type RemoteFailureContext = { readonly method?: string; readonly route?: string; readonly url?: string; }; /** * Defers building a {@link RemoteFailureContext} until a report is actually * rendered. * * The context describes a request SER never otherwise inspects, so resolving * it eagerly would read request-event properties on every remote call to * describe the few that fail. * * @example * ```ts * const resolve: ResolveRemoteFailureContext = () => ({ url: event.url.pathname }); * ``` * * @since 4.2.1 */ export type ResolveRemoteFailureContext = () => RemoteFailureContext | undefined; type Reporter = (message: string) => void; /** * Reports a remote failure that had to be replaced with an opaque envelope. * * SER cannot send an unrecognized failure to the browser, so the client only * ever sees a generic 500. Without this report the original error would be * lost entirely, which is the difference between a debuggable failure and a * silent one. * * @example * ```ts * report_opaque_remote_failure("untagged", cause, value, { url: "/checkout" }); * ``` * * @since 4.2.0 * @param reason - Why the failure could not be transported. * @param cause - Full Effect cause behind the failure. * @param value - The original failure value, when one was found. * @param context - Optional request detail for the log header. * @param report - Sink for the rendered report; defaults to `console.error`. */ export declare function report_opaque_remote_failure(reason: OpaqueRemoteFailureReason, cause: Cause.Cause, value: unknown, resolve_context?: ResolveRemoteFailureContext, report?: Reporter): void; /** * Renders the report emitted by {@link report_opaque_remote_failure}. * * @example * ```ts * const message = render_opaque_remote_failure("untagged", cause, value); * ``` * * @since 4.2.0 * @param reason - Why the failure could not be transported. * @param cause - Full Effect cause behind the failure. * @param value - The original failure value, when one was found. * @param context - Optional request detail for the log header. * @returns The multi-line report. */ export declare function render_opaque_remote_failure(reason: OpaqueRemoteFailureReason, cause: Cause.Cause, value: unknown, context?: RemoteFailureContext): string; export {};