{"version":3,"sources":["../src/cli/utils/formatFetchError.ts"],"sourcesContent":["import { formatApiErrorMessage } from \"../../client-sdk/services/_shared/format-api-error\";\n\n/**\n * Reads a failed fetch `Response` and produces a user-facing error message.\n * Tries to parse the body as JSON; falls back to the raw text. Status code is\n * threaded through as context for the formatter, so generic or empty bodies\n * at least surface \"status N\" to the user.\n */\nexport async function formatFetchError(response: Response): Promise<string> {\n  const errorBody = await response.text();\n  let parsed: unknown = errorBody;\n  try {\n    parsed = JSON.parse(errorBody);\n  } catch {\n    /* non-JSON body — pass through as-is */\n  }\n  return formatApiErrorMessage({\n    error: parsed,\n    options: { status: response.status },\n  });\n}\n"],"mappings":";;;;;AAQA,eAAsB,iBAAiB,UAAqC;AAC1E,QAAM,YAAY,MAAM,SAAS,KAAK;AACtC,MAAI,SAAkB;AACtB,MAAI;AACF,aAAS,KAAK,MAAM,SAAS;AAAA,EAC/B,SAAQ;AAAA,EAER;AACA,SAAO,sBAAsB;AAAA,IAC3B,OAAO;AAAA,IACP,SAAS,EAAE,QAAQ,SAAS,OAAO;AAAA,EACrC,CAAC;AACH;","names":[]}