Skip to content

HttpApiError

Built-in error schemas for common HTTP API failure responses.

This module provides reusable Schema.Error values for common HTTP status codes, plus HttpApiSchemaError for request decoding failures raised by the HTTP API runtime. The status errors can be used in endpoint or middleware error declarations and are understood by builders, generated clients, reflection, and OpenAPI generation.

29 exports Added in v4.0.0 Source

Errors

BadRequest

Added in v4.0.0 Source

Built-in HTTP API error for a 400 Bad Request response. When used directly as a server response, it renders as an empty response with status 400.

Signature

declare class BadRequest extends {
  readonly _tag: "BadRequest";
} & YieldableError<this> {
  constructor(...args: [props?: {
    readonly _tag?: "BadRequest";
  }, options?: MakeOptions]);
  readonly "~effect/ErrorReporter/ignore": true;
  static readonly singleton: BadRequest;
  "~effect/http/HttpServerRespondable"(): Effect<HttpServerResponse, never, never>;
}

Conflict

Added in v4.0.0 Source

Built-in HTTP API error for a 409 Conflict response. When used directly as a server response, it renders as an empty response with status 409.

Signature

declare class Conflict extends {
  readonly _tag: "Conflict";
} & YieldableError<this> {
  constructor(...args: [props?: {
    readonly _tag?: "Conflict";
  }, options?: MakeOptions]);
  readonly "~effect/ErrorReporter/ignore": true;
  "~effect/http/HttpServerRespondable"(): Effect<HttpServerResponse, never, never>;
}

Forbidden

Added in v4.0.0 Source

Built-in HTTP API error for a 403 Forbidden response. When used directly as a server response, it renders as an empty response with status 403.

Signature

declare class Forbidden extends {
  readonly _tag: "Forbidden";
} & YieldableError<this> {
  constructor(...args: [props?: {
    readonly _tag?: "Forbidden";
  }, options?: MakeOptions]);
  readonly "~effect/ErrorReporter/ignore": true;
  "~effect/http/HttpServerRespondable"(): Effect<HttpServerResponse, never, never>;
}

Gone

Added in v4.0.0 Source

Built-in HTTP API error for a 410 Gone response. When used directly as a server response, it renders as an empty response with status 410.

Signature

declare class Gone extends {
  readonly _tag: "Gone";
} & YieldableError<this> {
  constructor(...args: [props?: {
    readonly _tag?: "Gone";
  }, options?: MakeOptions]);
  readonly "~effect/ErrorReporter/ignore": true;
  "~effect/http/HttpServerRespondable"(): Effect<HttpServerResponse, never, never>;
}

Error raised when an HTTP API request or response component fails schema decoding or encoding. It records which component failed and responds as an empty 400 Bad Request when rendered as a server response.

Signature

declare class HttpApiSchemaError extends Readonly<{
  readonly cause: SchemaError;
  readonly kind: "Headers" | "Params" | "Query" | "Body" | "Payload" | "ResponseHeaders";
}> & {
  readonly _tag: "HttpApiSchemaError";
} & Pipeable {
  constructor(args: {
    readonly cause: SchemaError;
    readonly kind: "Headers" | "Params" | "Query" | "Body" | "Payload" | "ResponseHeaders";
  });
  readonly "~effect/httpapi/HttpApiError/HttpApiSchemaError": "~effect/httpapi/HttpApiError/HttpApiSchemaError";
  readonly message: "Headers" | "Params" | "Query" | "Body" | "Payload" | "ResponseHeaders";
  readonly name: "HttpApiSchemaError";
  "~effect/http/HttpServerRespondable"(): Effect<HttpServerResponse, never, never>;
  static is(u: unknown): u is HttpApiSchemaError;
  static wrap<A, R>(kind: "Headers" | "Params" | "Query" | "Body" | "Payload" | "ResponseHeaders", effect: Effect<A, SchemaError, R>): Effect<A, HttpApiSchemaError, R>;
}

Built-in HTTP API error for a 500 Internal Server Error response. When used directly as a server response, it renders as an empty response with status 500.

Signature

declare class InternalServerError extends {
  readonly _tag: "InternalServerError";
} & YieldableError<this> {
  constructor(...args: [props?: {
    readonly _tag?: "InternalServerError";
  }, options?: MakeOptions]);
  "~effect/http/HttpServerRespondable"(): Effect<HttpServerResponse, never, never>;
}

Built-in HTTP API error for a 405 Method Not Allowed response. When used directly as a server response, it renders as an empty response with status 405.

Signature

declare class MethodNotAllowed extends {
  readonly _tag: "MethodNotAllowed";
} & YieldableError<this> {
  constructor(...args: [props?: {
    readonly _tag?: "MethodNotAllowed";
  }, options?: MakeOptions]);
  readonly "~effect/ErrorReporter/ignore": true;
  "~effect/http/HttpServerRespondable"(): Effect<HttpServerResponse, never, never>;
}

Built-in HTTP API error for a 406 Not Acceptable response. When used directly as a server response, it renders as an empty response with status 406.

Signature

declare class NotAcceptable extends {
  readonly _tag: "NotAcceptable";
} & YieldableError<this> {
  constructor(...args: [props?: {
    readonly _tag?: "NotAcceptable";
  }, options?: MakeOptions]);
  readonly "~effect/ErrorReporter/ignore": true;
  "~effect/http/HttpServerRespondable"(): Effect<HttpServerResponse, never, never>;
}

NotFound

Added in v4.0.0 Source

Built-in HTTP API error for a 404 Not Found response. When used directly as a server response, it renders as an empty response with status 404.

Signature

declare class NotFound extends {
  readonly _tag: "NotFound";
} & YieldableError<this> {
  constructor(...args: [props?: {
    readonly _tag?: "NotFound";
  }, options?: MakeOptions]);
  readonly "~effect/ErrorReporter/ignore": true;
  "~effect/http/HttpServerRespondable"(): Effect<HttpServerResponse, never, never>;
}

Built-in HTTP API error for a 501 Not Implemented response. When used directly as a server response, it renders as an empty response with status 501.

Signature

declare class NotImplemented extends {
  readonly _tag: "NotImplemented";
} & YieldableError<this> {
  constructor(...args: [props?: {
    readonly _tag?: "NotImplemented";
  }, options?: MakeOptions]);
  "~effect/http/HttpServerRespondable"(): Effect<HttpServerResponse, never, never>;
}

Built-in HTTP API error for a 408 Request Timeout response. When used directly as a server response, it renders as an empty response with status 408.

Signature

declare class RequestTimeout extends {
  readonly _tag: "RequestTimeout";
} & YieldableError<this> {
  constructor(...args: [props?: {
    readonly _tag?: "RequestTimeout";
  }, options?: MakeOptions]);
  readonly "~effect/ErrorReporter/ignore": true;
  "~effect/http/HttpServerRespondable"(): Effect<HttpServerResponse, never, never>;
}

Built-in HTTP API error for a 503 Service Unavailable response. When used directly as a server response, it renders as an empty response with status 503.

Signature

declare class ServiceUnavailable extends {
  readonly _tag: "ServiceUnavailable";
} & YieldableError<this> {
  constructor(...args: [props?: {
    readonly _tag?: "ServiceUnavailable";
  }, options?: MakeOptions]);
  "~effect/http/HttpServerRespondable"(): Effect<HttpServerResponse, never, never>;
}

Unauthorized

Added in v4.0.0 Source

Built-in HTTP API error for a 401 Unauthorized response. When used directly as a server response, it renders as an empty response with status 401.

Signature

declare class Unauthorized extends {
  readonly _tag: "Unauthorized";
} & YieldableError<this> {
  constructor(...args: [props?: {
    readonly _tag?: "Unauthorized";
  }, options?: MakeOptions]);
  readonly "~effect/ErrorReporter/ignore": true;
  "~effect/http/HttpServerRespondable"(): Effect<HttpServerResponse, never, never>;
}

Built-in HTTP API error for a 422 Unprocessable Entity response. When used directly as a server response, it renders as an empty response with status 422.

Signature

declare class UnprocessableEntity extends {
  readonly _tag: "UnprocessableEntity";
} & YieldableError<this> {
  constructor(...args: [props?: {
    readonly _tag?: "UnprocessableEntity";
  }, options?: MakeOptions]);
  readonly "~effect/ErrorReporter/ignore": true;
  "~effect/http/HttpServerRespondable"(): Effect<HttpServerResponse, never, never>;
}

Schemas

No-content schema variant for BadRequest, decoding an empty 400 response into a BadRequest error value.

Signature

declare const BadRequestNoContent: asNoContent<typeof BadRequest>;

No-content schema variant for Conflict, decoding an empty 409 response into a Conflict error value.

Signature

declare const ConflictNoContent: asNoContent<typeof Conflict>;

No-content schema variant for Forbidden, decoding an empty 403 response into a Forbidden error value.

Signature

declare const ForbiddenNoContent: asNoContent<typeof Forbidden>;

No-content schema variant for Gone, decoding an empty 410 response into a Gone error value.

Signature

declare const GoneNoContent: asNoContent<typeof Gone>;

No-content schema variant for InternalServerError, decoding an empty 500 response into an InternalServerError error value.

Signature

declare const InternalServerErrorNoContent: asNoContent<typeof InternalServerError>;

No-content schema variant for MethodNotAllowed, decoding an empty 405 response into a MethodNotAllowed error value.

Signature

declare const MethodNotAllowedNoContent: asNoContent<typeof MethodNotAllowed>;

No-content schema variant for NotAcceptable, decoding an empty 406 response into a NotAcceptable error value.

Signature

declare const NotAcceptableNoContent: asNoContent<typeof NotAcceptable>;

No-content schema variant for NotFound, decoding an empty 404 response into a NotFound error value.

Signature

declare const NotFoundNoContent: asNoContent<typeof NotFound>;

No-content schema variant for NotImplemented, decoding an empty 501 response into a NotImplemented error value.

Signature

declare const NotImplementedNoContent: asNoContent<typeof NotImplemented>;

No-content schema variant for RequestTimeout, decoding an empty 408 response into a RequestTimeout error value.

Signature

declare const RequestTimeoutNoContent: asNoContent<typeof RequestTimeout>;

No-content schema variant for ServiceUnavailable, decoding an empty 503 response into a ServiceUnavailable error value.

Signature

declare const ServiceUnavailableNoContent: asNoContent<typeof ServiceUnavailable>;

No-content schema variant for Unauthorized, decoding an empty 401 response into an Unauthorized error value.

Signature

declare const UnauthorizedNoContent: asNoContent<typeof Unauthorized>;

No-content schema variant for UnprocessableEntity, decoding an empty 422 response into an UnprocessableEntity error value.

Signature

declare const UnprocessableEntityNoContent: asNoContent<typeof UnprocessableEntity>;

Type IDs

Runtime identifier used to mark and detect HttpApiSchemaError values.

Signature

declare const HttpApiSchemaErrorTypeId: "~effect/httpapi/HttpApiError/HttpApiSchemaError";

Type-level identifier used to mark HttpApiSchemaError values.

Signature

type HttpApiSchemaErrorTypeId = "~effect/httpapi/HttpApiError/HttpApiSchemaError";