UNPKG

@wandelbots/nova-js

Version:

Official JS client for the Wandelbots API

36 lines (34 loc) 2.27 kB
import { n as availableStorage, r as AutoReconnectingWebsocket, t as loginWithAuth0 } from "./LoginWithAuth0-wQB-Sol1.mjs"; import { c as degreesToRadians, d as radiansToDegrees, f as tryParseJson, l as isSameCoordinateSystem, o as poseToWandelscriptString, p as tryStringifyJson, s as XYZ_TO_VECTOR, t as NovaClient, u as makeUrlQueryString } from "./NovaClient-B8XM3OPO.mjs"; import { AxiosError } from "axios"; //#region src/lib/errorHandling.ts function delay(ms) { return new Promise((resolve) => setTimeout(resolve, ms)); } /** * @deprecated Use makeErrorMessage instead and truncate the error for display as needed, or make a situation-specific localized error message based on a response code */ function makeShortErrorMessage(err) { return makeErrorMessage(err); } /** * Attempts to make a helpful error message from an unknown thrown error * or promise rejection. * * This function is mainly to aid debugging and good bug reports. For * expected errors encountered by end users, it's more ideal to catch * the specific error code and provide a localized app-specific error message. */ function makeErrorMessage(err) { if (err instanceof AxiosError) { if (err.response) return `${err.response?.status} ${err.response?.statusText} from ${err.response?.config.method?.toUpperCase() || "accessing"} ${err.response?.config.url}: ${JSON.stringify(err.response?.data)}`; else if (err.config) if (err.code === "ERR_NETWORK") return `${err.message} from ${err.config.method?.toUpperCase() || "accessing"} ${err.config.url}. This error can happen because of either connection issues or server CORS policy.`; else return `${err.message} from ${err.config.method?.toUpperCase() || "accessing"} ${err.config.url}`; } else if (err instanceof Error) return err.message; else if (typeof err === "string") return err; else if (typeof err === "object") return tryStringifyJson(err) || `Unserializable object ${err}`; return `${err}`; } //#endregion export { AutoReconnectingWebsocket, NovaClient, XYZ_TO_VECTOR, availableStorage, degreesToRadians, delay, isSameCoordinateSystem, loginWithAuth0, makeErrorMessage, makeShortErrorMessage, makeUrlQueryString, poseToWandelscriptString, radiansToDegrees, tryParseJson, tryStringifyJson }; //# sourceMappingURL=index.mjs.map