Skip to content

Status

A response whose status is outside 200..=299.

Raised by a request that completes normally but reports a failure status, unless status: :IGNORE: was passed. The response metadata and the first 64 KiB of the body are kept on the error, so a failed request can be diagnosed without a second round trip.

Example

try
  get "https://example.com/missing"
catch Status: err
  echo $err.status
  echo $err.text()

Inherits from: Error

Fields

headers @ Dict[Str, Str | time.DateTime]

The response headers, as Response.headers presents them.

status @ Int

The HTTP status code.

truncated @ Bool

Whether the saved body excerpt was cut off, either by the 64 KiB limit or by a read error while buffering it.

url @ (url.Url | nil)

The response URL, or nil when none was attached.

Methods

body() -> Bin

The saved body excerpt.

json() -> json.Data

The saved body excerpt, parsed as JSON.

Available when the extension is built with its json feature.

text() -> Str

The saved body excerpt as text.

Errors

Exception Condition
ValueError The excerpt is not valid UTF-8