Skip to content

Errors

ClassWhen
TriasErrorBase class for library errors
TriasHttpErrorHTTP status is not OK
TriasParseErrorResponse 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.

Thrown when the endpoint returns a non-success HTTP status.

Fields:

  • statusCode: numeric HTTP status
  • responseBody: response text as returned by the server
  • requestXml: the XML string that was posted

Use this for logging, retries, or surfacing operator-specific error pages.

Thrown when XML parsing fails after a successful HTTP response.

Fields:

  • xml: the response body that could not be parsed
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;
}
}