class UnsupportedFormEncodingError
extends Error
Since 0.5.0

Raised when a request body is not a form encoding the framework can parse: a JSON body, a missing content-type, or a multipart/form-data type carrying no boundary=.

Self-branded 415 Unsupported Media Type in its own constructor — the MalformedRequestBodyError precedent (X37-1) — so a body that is not a form is answered 415 in the application's configured format instead of the masked 500 an unbranded throw from body depth would produce. A handler that catches its own formData() rejection keeps full control of what is served; the class is exported so that catch can use instanceof.

It is deliberately NOT thrown for a multipart body the parser cannot make sense of: that yields an empty FormBody, the promoted parser's released behaviour, documented on the accessor rather than converted into a status here.

Examples

Example 1

try {
  const form = await ctx.request.formData();
} catch (error) {
  if (error instanceof UnsupportedFormEncodingError) {
    // Not a form body — answer 415 or read the body another way.
  }
}

Constructors

UnsupportedFormEncodingError()

Builds the rejection for a content-type that is neither form encoding.

The caller-facing detail names the two supported encodings and never echoes the request's own content-type value: it is client-controlled, and the detail is served verbatim in an unauthenticated response body.

Properties

readonly
name: string

Discriminant for consumers that cannot use instanceof across realms.

Usage

import { UnsupportedFormEncodingError } from "common/src/index.ts";