/**
 * Error model used by the unstable HTTP server runtime.
 *
 * This module defines the tagged failures that can occur while a server accepts
 * a request, matches a route, runs a handler, or builds and sends a response.
 * Request-scoped failures keep the request that caused them, and response
 * failures keep the response that was being produced, so applications can log,
 * report, or translate failures without reconstructing HTTP context.
 *
 * **Mental model**
 *
 * {@link HttpServerError} wraps a concrete {@link HttpServerErrorReason}.
 * {@link RequestParseError}, {@link RouteNotFound}, and {@link InternalError}
 * describe failures before or during request handling, while
 * {@link ResponseError} describes a failure tied to a response that was already
 * being built or sent. {@link ServeError} represents lower-level server
 * implementation failures outside an individual handler response.
 *
 * **Common tasks**
 *
 * Use {@link isHttpServerError} to refine unknown failures, inspect `request`
 * and `response` when reporting failures, and use {@link causeResponse} or
 * {@link exitResponse} when a handler cause or exit must be translated into the
 * HTTP response sent to the client.
 *
 * **Gotchas**
 *
 * The default response mapping is intentionally small: request parse errors
 * become `400`, route misses become ignored `404` failures, internal and
 * response errors become `500`, client aborts marked with {@link ClientAbort}
 * become `499`, and server-side interrupts become `503`. A
 * {@link ResponseError} does not reuse the failed response when converted; it
 * produces an empty `500` because that response may be invalid or partly sent.
 *
 * @since 4.0.0
 */
import * as Cause from "../../Cause.ts";
import * as Context from "../../Context.ts";
import * as Effect from "../../Effect.ts";
import * as ErrorReporter from "../../ErrorReporter.ts";
import type * as Exit from "../../Exit.ts";
import * as Option from "../../Option.ts";
import type * as Request from "./HttpServerRequest.ts";
import * as Respondable from "./HttpServerRespondable.ts";
import * as Response from "./HttpServerResponse.ts";
declare const TypeId = "~effect/http/HttpServerError";
declare const HttpServerError_base: new <A extends Record<string, any> = {}>(args: import("../../Types.ts").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => Cause.YieldableError & {
    readonly _tag: "HttpServerError";
} & Readonly<A>;
/**
 * Tagged error for failures that occur while handling an HTTP server request.
 *
 * **Details**
 *
 * It wraps a `HttpServerErrorReason`, exposes the associated request and optional
 * response, and can be converted to an HTTP response through the `Respondable`
 * protocol.
 *
 * @category errors
 * @since 4.0.0
 */
export declare class HttpServerError extends HttpServerError_base<{
    readonly reason: HttpServerErrorReason;
}> implements Respondable.Respondable {
    constructor(props: {
        readonly reason: HttpServerErrorReason;
    });
    readonly [TypeId] = "~effect/http/HttpServerError";
    stack: string;
    get request(): Request.HttpServerRequest;
    get response(): Response.HttpServerResponse | undefined;
    [Respondable.symbol](): Effect.Effect<Response.HttpServerResponse, never, never>;
    get [ErrorReporter.ignore](): boolean;
    get message(): string;
}
declare const RequestParseError_base: new <A extends Record<string, any> = {}>(args: import("../../Types.ts").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => Cause.YieldableError & {
    readonly _tag: "RequestParseError";
} & Readonly<A>;
/**
 * Error describing a failure to parse or read an incoming request.
 *
 * **Details**
 *
 * When converted to a response it produces an empty `400` response.
 *
 * @category errors
 * @since 4.0.0
 */
export declare class RequestParseError extends RequestParseError_base<{
    readonly request: Request.HttpServerRequest;
    readonly description?: string;
    readonly cause?: unknown;
}> implements Respondable.Respondable {
    /**
     * Converts the request error into a `400 Bad Request` response.
     *
     * @since 4.0.0
     */
    [Respondable.symbol](): Effect.Effect<Response.HttpServerResponse, never, never>;
    get methodAndUrl(): string;
    get message(): string;
}
declare const RouteNotFound_base: new <A extends Record<string, any> = {}>(args: import("../../Types.ts").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => Cause.YieldableError & {
    readonly _tag: "RouteNotFound";
} & Readonly<A>;
/**
 * Error indicating that no route matched the incoming request.
 *
 * **Details**
 *
 * When converted to a response it produces an empty `404` response, and it is
 * ignored by the error reporter.
 *
 * @category errors
 * @since 4.0.0
 */
export declare class RouteNotFound extends RouteNotFound_base<{
    readonly request: Request.HttpServerRequest;
    readonly description?: string;
    readonly cause?: unknown;
}> implements Respondable.Respondable {
    [Respondable.symbol](): Effect.Effect<Response.HttpServerResponse, never, never>;
    readonly [ErrorReporter.ignore] = true;
    get methodAndUrl(): string;
    get message(): string;
}
declare const InternalError_base: new <A extends Record<string, any> = {}>(args: import("../../Types.ts").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => Cause.YieldableError & {
    readonly _tag: "InternalError";
} & Readonly<A>;
/**
 * Error describing an unexpected server-side failure while handling a request.
 *
 * **Details**
 *
 * When converted to a response it produces an empty `500` response.
 *
 * @category errors
 * @since 4.0.0
 */
export declare class InternalError extends InternalError_base<{
    readonly request: Request.HttpServerRequest;
    readonly description?: string;
    readonly cause?: unknown;
}> implements Respondable.Respondable {
    /**
     * Converts the server error into a `500 Internal Server Error` response.
     *
     * @since 4.0.0
     */
    [Respondable.symbol](): Effect.Effect<Response.HttpServerResponse, never, never>;
    get methodAndUrl(): string;
    get message(): string;
}
/**
 * Returns `true` when the supplied value is an `HttpServerError`.
 *
 * @category predicates
 * @since 4.0.0
 */
export declare const isHttpServerError: (u: unknown) => u is HttpServerError;
declare const ResponseError_base: new <A extends Record<string, any> = {}>(args: import("../../Types.ts").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => Cause.YieldableError & {
    readonly _tag: "ResponseError";
} & Readonly<A>;
/**
 * Error describing a failure related to an HTTP response.
 *
 * **Details**
 *
 * It carries the request and response involved in the failure. When converted to
 * a response it produces an empty `500` response.
 *
 * @category errors
 * @since 4.0.0
 */
export declare class ResponseError extends ResponseError_base<{
    readonly request: Request.HttpServerRequest;
    readonly response: Response.HttpServerResponse;
    readonly description?: string;
    readonly cause?: unknown;
}> implements Respondable.Respondable {
    [Respondable.symbol](): Effect.Effect<Response.HttpServerResponse, never, never>;
    get methodAndUrl(): string;
    get message(): string;
}
/**
 * Union of errors that are tied directly to an incoming server request.
 *
 * @category errors
 * @since 4.0.0
 */
export type RequestError = RequestParseError | RouteNotFound | InternalError;
/**
 * Reason carried by an `HttpServerError`, either a request-level error or a response-level error.
 *
 * @category errors
 * @since 4.0.0
 */
export type HttpServerErrorReason = RequestError | ResponseError;
declare const ServeError_base: new <A extends Record<string, any> = {}>(args: import("../../Types.ts").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => Cause.YieldableError & {
    readonly _tag: "ServeError";
} & Readonly<A>;
/**
 * Error wrapping a low-level failure from the HTTP server implementation.
 *
 * @category errors
 * @since 4.0.0
 */
export declare class ServeError extends ServeError_base<{
    readonly cause: unknown;
}> {
}
declare const ClientAbort_base: Context.ServiceClass<ClientAbort, "effect/http/HttpServerError/ClientAbort", true>;
/**
 * Context annotation used to mark an interrupt as caused by the client aborting
 * the request.
 *
 * **Details**
 *
 * `causeResponse` uses this annotation to map a pure client abort to a `499`
 * response instead of a server abort response.
 *
 * @category annotations
 * @since 4.0.0
 */
export declare class ClientAbort extends ClientAbort_base {
    static annotation: Context.Context<Cause.StackTrace | ClientAbort>;
}
/**
 * Converts a failed handler cause into the HTTP response that should be sent and
 * the cause that should be reported.
 *
 * **Details**
 *
 * Respondable failures and defects can choose their own response, defects that
 * are already `HttpServerResponse` values are used directly, and pure interrupts
 * produce either `499` for client aborts or `503` for server aborts.
 *
 * @category error handling
 * @since 4.0.0
 */
export declare const causeResponse: <E>(cause: Cause.Cause<E>) => Effect.Effect<readonly [Response.HttpServerResponse, Cause.Cause<E>]>;
/**
 * Derives an HTTP response from a failed handler cause synchronously.
 *
 * **Details**
 *
 * If the cause contains a defect that is already an `HttpServerResponse`, that
 * response is used and removed from the remaining cause. Otherwise the response
 * defaults to `500`.
 *
 * @category error handling
 * @since 4.0.0
 */
export declare const causeResponseStripped: <E>(cause: Cause.Cause<E>) => readonly [response: Response.HttpServerResponse, cause: Option.Option<Cause.Cause<E>>];
/**
 * Extracts the response from a successful handler exit, or derives a response
 * from the failure cause.
 *
 * @category error handling
 * @since 4.0.0
 */
export declare const exitResponse: <E>(exit: Exit.Exit<Response.HttpServerResponse, E>) => Response.HttpServerResponse;
export {};
//# sourceMappingURL=HttpServerError.d.ts.map