@wandelbots/nova-js
Version:
Official JS client for the Wandelbots API
86 lines (82 loc) • 2.89 kB
JavaScript
import {
baseGetTag_default,
isArray_default,
isObjectLike_default,
isObject_default
} from "./chunk-6WCKJOFL.js";
import {
AutoReconnectingWebsocket,
availableStorage,
degreesToRadians,
isSameCoordinateSystem,
loginWithAuth0,
makeUrlQueryString,
poseToWandelscriptString,
radiansToDegrees,
tryParseJson,
tryStringifyJson
} from "./chunk-V3NJLR6P.js";
// src/lib/errorHandling.ts
import { AxiosError } from "axios";
// node_modules/lodash-es/isString.js
var stringTag = "[object String]";
function isString(value) {
return typeof value == "string" || !isArray_default(value) && isObjectLike_default(value) && baseGetTag_default(value) == stringTag;
}
var isString_default = isString;
// src/lib/errorHandling.ts
function delay(ms) {
return new Promise((resolve) => setTimeout(resolve, ms));
}
function makeShortErrorMessage(err) {
return makeErrorMessage(err);
}
function makeErrorMessage(err) {
var _a, _b, _c, _d, _e, _f, _g, _h;
if (err instanceof AxiosError) {
if (err.response) {
return `${(_a = err.response) == null ? void 0 : _a.status} ${(_b = err.response) == null ? void 0 : _b.statusText} from ${((_d = (_c = err.response) == null ? void 0 : _c.config.method) == null ? void 0 : _d.toUpperCase()) || "accessing"} ${(_e = err.response) == null ? void 0 : _e.config.url}: ${JSON.stringify((_f = err.response) == null ? void 0 : _f.data)}`;
} else if (err.config) {
if (err.code === "ERR_NETWORK") {
return `${err.message} from ${((_g = err.config.method) == null ? void 0 : _g.toUpperCase()) || "accessing"} ${err.config.url}. This error can happen because of either connection issues or server CORS policy.`;
} else {
return `${err.message} from ${((_h = err.config.method) == null ? void 0 : _h.toUpperCase()) || "accessing"} ${err.config.url}`;
}
}
} else if (err instanceof Error) {
return err.message;
} else if (isString_default(err)) {
return err;
} else if (isObject_default(err)) {
return tryStringifyJson(err) || `Unserializable object ${err}`;
}
return `${err}`;
}
export {
AutoReconnectingWebsocket,
availableStorage,
degreesToRadians,
delay,
isSameCoordinateSystem,
loginWithAuth0,
makeErrorMessage,
makeShortErrorMessage,
makeUrlQueryString,
poseToWandelscriptString,
radiansToDegrees,
tryParseJson,
tryStringifyJson
};
/*! Bundled license information:
lodash-es/lodash.js:
(**
* @license
* Lodash (Custom Build) <https://lodash.com/>
* Build: `lodash modularize exports="es" -o ./`
* Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
* Released under MIT license <https://lodash.com/license>
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
*)
*/
//# sourceMappingURL=index.js.map