{"version":3,"file":"parseError.mjs","names":[],"sources":["../../../src/runtime/utils/parseError.ts"],"sourcesContent":["import type { FetchError } from 'ofetch'\nimport type { ParsedError } from '../../types'\n\nexport type { ParsedError }\n\nexport function parseError(error: unknown): ParsedError {\n  if (error && typeof error === 'object' && 'data' in error) {\n    const { data, message: fetchMessage, statusCode: fetchStatusCode, status: fetchStatus } = error as FetchError & { status?: number }\n\n    // Support both nested data.data (fetch response) and direct data (MxllogError)\n    const mxllogData = (data?.data ?? data) as { why?: string, fix?: string, link?: string } | undefined\n\n    return {\n      // Prefer statusText, then statusMessage (or message) for the error message\n      message: data?.statusText || data?.statusMessage || data?.message || fetchMessage || 'An error occurred',\n      // Prefer status, then statusCode for the status value\n      status: data?.status || data?.statusCode || fetchStatus || fetchStatusCode || 500,\n      why: mxllogData?.why,\n      fix: mxllogData?.fix,\n      link: mxllogData?.link,\n      raw: error,\n    }\n  }\n\n  if (error instanceof Error) {\n    return {\n      message: error.message,\n      status: 500,\n      raw: error,\n    }\n  }\n\n  return {\n    message: String(error),\n    status: 500,\n    raw: error,\n  }\n}\n"],"mappings":";AAKA,SAAgB,WAAW,OAA6B;AACtD,KAAI,SAAS,OAAO,UAAU,YAAY,UAAU,OAAO;EACzD,MAAM,EAAE,MAAM,SAAS,cAAc,YAAY,iBAAiB,QAAQ,gBAAgB;EAG1F,MAAM,aAAc,MAAM,QAAQ;AAElC,SAAO;GAEL,SAAS,MAAM,cAAc,MAAM,iBAAiB,MAAM,WAAW,gBAAgB;GAErF,QAAQ,MAAM,UAAU,MAAM,cAAc,eAAe,mBAAmB;GAC9E,KAAK,YAAY;GACjB,KAAK,YAAY;GACjB,MAAM,YAAY;GAClB,KAAK;GACN;;AAGH,KAAI,iBAAiB,MACnB,QAAO;EACL,SAAS,MAAM;EACf,QAAQ;EACR,KAAK;EACN;AAGH,QAAO;EACL,SAAS,OAAO,MAAM;EACtB,QAAQ;EACR,KAAK;EACN"}