Class: DataONEHttpError

DataONEHttpError()

Normalized transport error for DataONEHttpClient. Accepts any available metadata (response, status, body text, network error, etc.) and derives a consistent error shape.

DataONEHttpError(options)

new DataONEHttpError(options)

Build a normalized HTTP error.
Parameters:
Name Type Description
options object An options object.
Properties
Name Type Attributes Description
message string <optional>
Error message; when omitted a sensible default is derived.
status number | string | null <optional>
HTTP status code.
url string <optional>
Request URL.
attempt number <optional>
Attempt number (1-based).
networkError boolean <optional>
Whether the failure was a network error.
headers Headers | object | null <optional>
Response headers when available.
response object | null <optional>
Response-like object with `status`, `url`, `headers`, and `data` or `bodyText`.
bodyText string | null <optional>
Response body to attach (truncated).
error Error <optional>
Original thrown error for context.
maxErrorBody number <optional>
Body truncation limit.
Source:

Methods

truncateBody(text, maxCharsopt) → {string|null}

Truncate a response body string.
Parameters:
Name Type Attributes Description
text string Text to truncate.
maxChars number <optional>
Maximum length.
Source:
Returns:
Truncated text or null.
Type
string | null