{"version":3,"file":"index5.cjs","sources":["../src/errors.ts"],"sourcesContent":["type Options = {\n  statusCode: number\n  payload: string\n}\n\nexport class IncogniaApiError extends Error {\n  readonly statusCode?: number\n  readonly payload?: string\n\n  constructor(message: string, options?: Options) {\n    super(message)\n    this.name = 'IncogniaApiError'\n    this.statusCode = options?.statusCode\n    this.payload = options?.payload\n  }\n}\n\nexport class IncogniaError extends Error {\n  constructor(message: string) {\n    super(message)\n    this.name = 'IncogniaError'\n  }\n}\n\nexport type CustomRequestError = {\n  message: string\n  response?: {\n    status: number\n    data: string\n  }\n  request?: object\n}\n\nexport function throwCustomRequestError(e: CustomRequestError) {\n  if (e.response) {\n    throw new IncogniaApiError(e.message, {\n      statusCode: e.response.status,\n      payload: e.response.data\n    })\n  }\n\n  if (e.request) {\n    throw new IncogniaApiError(\n      `The request was made but no response was received (${e.message})`\n    )\n  }\n\n  throw new IncogniaError(e.message)\n}\n"],"names":["IncogniaApiError","message","options","IncogniaError","throwCustomRequestError","e"],"mappings":"gFAKO,MAAMA,UAAyB,KAAM,CAI1C,YAAYC,EAAiBC,EAAmB,CAC9C,MAAMD,CAAO,EACb,KAAK,KAAO,mBACZ,KAAK,WAAaC,GAAS,WAC3B,KAAK,QAAUA,GAAS,OAC1B,CACF,CAEO,MAAMC,UAAsB,KAAM,CACvC,YAAYF,EAAiB,CAC3B,MAAMA,CAAO,EACb,KAAK,KAAO,eACd,CACF,CAWO,SAASG,EAAwBC,EAAuB,CAC7D,MAAIA,EAAE,SACE,IAAIL,EAAiBK,EAAE,QAAS,CACpC,WAAYA,EAAE,SAAS,OACvB,QAASA,EAAE,SAAS,IAAA,CACrB,EAGCA,EAAE,QACE,IAAIL,EACR,sDAAsDK,EAAE,OAAO,GAAA,EAI7D,IAAIF,EAAcE,EAAE,OAAO,CACnC"}