1import { o as __toESM, t as __commonJSMin } from "./chunk-6z4oVpB-.js"; 2import { m as isRouteErrorResponse } from "./chunk-62JRHF6Z-af5QuQJC.js"; 3var require_isObject = /* @__PURE__ */ __commonJSMin(((exports, module) => { 4 function isObject$1(value) { 5 var type = typeof value; 6 return value != null && (type == "object" || type == "function"); 7 } 8 module.exports = isObject$1; 9})); 10var import_isObject = /* @__PURE__ */ __toESM(require_isObject()); 11var ERROR_RESPONSE__MESSAGES = { 12 400: "The server encountered an error.", 13 401: "You do not have access to view this page.", 14 403: "You lack permissions to perform this action.", 15 404: "We canât find the page youâre looking for.", 16 500: "The server encountered an error. Please try again." 17}; 18var DEFAULT_ERROR = "Something went wrong."; 19function getErrorResponseMessage(status) { 20 return status ? ERROR_RESPONSE__MESSAGES[status] || DEFAULT_ERROR : DEFAULT_ERROR; 21} 22function getMessageFromErrorResponse(error) { 23 const { status } = getError(error); 24 return getErrorResponseMessage(status); 25} 26function getError(error) { 27 if (isRouteErrorResponse(error)) { 28 if (typeof error.data === "string") return { 29 message: error.data, 30 status: error.status, 31 statusText: error.statusText 32 }; 33 else if ("error" in error.data && "message" in error.data.error) return { 34 status: error.status, 35 statusText: error.statusText 36 }; 37 } 38 if (error instanceof Response) { 39 const status = error.status; 40 const statusText = error.statusText; 41 return { 42 message: statusText || `HTTP ${status}`, 43 status, 44 statusText 45 }; 46 } 47 if (error instanceof Error) return { message: error.message }; 48 return { message: (0, import_isObject.default)(error) ? JSON.stringify(error) : String(error) }; 49} 50function _getErrorMessage(error) { 51 if (error instanceof Error) return error.message; 52 return { message: (0, import_isObject.default)(error) ? JSON.stringify(error) : String(error) }; 53} 54function _getErrorResponseMessage(error) { 55 if (isRouteErrorResponse(error)) { 56 if ("error" in error.data && "message" in error.data.error) return error.data.error.message; 57 else if (error.data) return JSON.stringify(error.data); 58 } 59 return _getErrorMessage(error); 60} 61export { getMessageFromErrorResponse as a, getErrorResponseMessage as i, _getErrorResponseMessage as n, require_isObject as o, getError as r, _getErrorMessage as t }; 62 63//# sourceMappingURL=errors-Bz8_MS_m.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.