Errors
Overview
Section titled “Overview”| Class | When |
|---|---|
TriasError | Base class for library errors |
TriasHttpError | HTTP status is not OK |
TriasParseError | Response body is not valid XML for the parser |
The constructor validates required TriasClient options (endpoint, requestorRef) and throws a plain Error if they are missing.
TriasHttpError
Section titled “TriasHttpError”Thrown when the endpoint returns a non-success HTTP status.
Fields:
statusCode: numeric HTTP statusresponseBody: response text as returned by the serverrequestXml: the XML string that was posted
Use this for logging, retries, or surfacing operator-specific error pages.
TriasParseError
Section titled “TriasParseError”Thrown when XML parsing fails after a successful HTTP response.
Fields:
xml: the response body that could not be parsed
Example
Section titled “Example”import { TriasClient, TriasHttpError, TriasParseError } from "trias-js";
const client = new TriasClient({ endpoint: "https://example.com/trias", requestorRef: "YOUR_REF",});
try { await client.locationInformation({ locationName: "Hbf" });} catch (e) { if (e instanceof TriasHttpError) { console.error(e.statusCode, e.responseBody); } else if (e instanceof TriasParseError) { console.error(e.message, e.xml.slice(0, 500)); } else { throw e; }}