{"version":3,"sources":["../src/http/parse-error.ts"],"sourcesContent":["import { ContentstackError } from \"./errors.js\"\n\n/**\n * Parse a non-ok fetch Response into a ContentstackError.\n *\n * Handles the Contentstack API error format (error_message, error_code, errors)\n * and falls back to the HTTP status text when the body is not parseable.\n *\n * This is a shared utility used by React hooks and Vue composables to avoid\n * duplicating error-parsing logic across frameworks.\n */\nexport async function parseErrorResponse(\n  response: Response,\n  path: string,\n): Promise<ContentstackError> {\n  try {\n    const body = await response.json()\n    return new ContentstackError(body.error_message ?? body.message ?? response.statusText, {\n      status: response.status,\n      errorCode: body.error_code,\n      errors: body.errors,\n      requestPath: path,\n    })\n  } catch {\n    return new ContentstackError(response.statusText, {\n      status: response.status,\n      requestPath: path,\n    })\n  }\n}\n"],"mappings":";;;;;AAWA,eAAsB,mBACpB,UACA,MAC4B;AAC5B,MAAI;AACF,UAAM,OAAO,MAAM,SAAS,KAAK;AACjC,WAAO,IAAI,kBAAkB,KAAK,iBAAiB,KAAK,WAAW,SAAS,YAAY;AAAA,MACtF,QAAQ,SAAS;AAAA,MACjB,WAAW,KAAK;AAAA,MAChB,QAAQ,KAAK;AAAA,MACb,aAAa;AAAA,IACf,CAAC;AAAA,EACH,QAAQ;AACN,WAAO,IAAI,kBAAkB,SAAS,YAAY;AAAA,MAChD,QAAQ,SAAS;AAAA,MACjB,aAAa;AAAA,IACf,CAAC;AAAA,EACH;AACF;","names":[]}