Errors
RFC 9457 Problem Details — TrustlessWorkApiError, TrustlessWorkNetworkError, and helpers.
HTTP failures from Core are RFC 9457 Problem Details. The fetch transport surfaces them as TrustlessWorkApiError. Non-problem HTTP failures throw TrustlessWorkNetworkError.
Core exports
import {
toTrustlessWorkError,
TrustlessWorkApiError,
TrustlessWorkNetworkError,
formatApiErrorMessage,
parseProblemDetails,
parseProblemDetailsFromResponse,
isProblemDetails,
ESCROW_ERROR_CODES,
isEscrowErrorCode,
} from "@trustless-work/escrow-js";toTrustlessWorkError
Normalize thrown values → TrustlessWorkApiError when body is Problem Details
TrustlessWorkApiError
Typed error with code, status, detail, traceId, extensions, …
TrustlessWorkNetworkError
Non-problem HTTP failure (status + raw body)
formatApiErrorMessage
One-liner for logs ([CODE] detail (trace: …))
parseProblemDetails
Parse unknown JSON into ApiProblemDetails
parseProblemDetailsFromResponse
Extract Problem Details from status + body (fetch equivalent of Axios helper)
isProblemDetails
Type guard
ESCROW_ERROR_CODES / isEscrowErrorCode
Known escrow machine codes
Example
TrustlessWorkApiError fields
status
HTTP status
code
Machine-readable code
detail / message
Human detail
traceId
Correlation id
type / title / instance
Problem Details metadata
extensions
Optional escrow extensions
isEscrowError() / asEscrowProblem()
Narrow to known escrow codes