Skip to content

Status

Status is raised when an HTTP request completes but returns a status outside 200..=299.

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

The error stores response metadata and the first 64 KiB of the response body.

Inherits

Fields

status

The HTTP status code.

headers

A dict-like view of the response headers. See Response.headers for details.

Type

Dict-like

url

The response URL as url.Url, or nil if none was attached.

truncated

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

Methods

body

Returns the saved body excerpt as Bin.

text

Returns the saved body excerpt as Str, failing on invalid UTF-8.

json

When the json feature is enabled, parses the saved body excerpt as JSON.