UNPKG

node-csfd-api

Version:

ČSFD API in JavaScript. Amazing NPM library for scrapping csfd.cz :)

1 lines 1.54 kB
{"version":3,"file":"errors.cjs","names":["LIB_PREFIX"],"sources":["../src/errors.ts"],"sourcesContent":["import { LIB_PREFIX } from './vars';\n\nexport type CsfdErrorReason =\n /** An anti-bot challenge stood in the way and could not be passed. */\n | 'blocked'\n /** ČSFD answered 404 — the movie, creator or user does not exist. */\n | 'not-found'\n /** Any other unsuccessful HTTP status. */\n | 'http'\n /** The request never completed: offline, DNS, TLS, timeout. */\n | 'network';\n\ninterface CsfdErrorOptions {\n status?: number;\n cause?: unknown;\n}\n\n/**\n * Raised when a page cannot be retrieved. `reason` says why, so callers can\n * tell \"this movie does not exist\" from \"ČSFD is refusing us right now\" and\n * react differently instead of guessing from a message.\n */\nexport class CsfdError extends Error {\n readonly reason: CsfdErrorReason;\n readonly url: string;\n /** HTTP status, when the request got far enough to have one. */\n readonly status?: number;\n\n constructor(reason: CsfdErrorReason, url: string, message: string, options?: CsfdErrorOptions) {\n super(`${LIB_PREFIX} ${message}`, { cause: options?.cause });\n this.name = 'CsfdError';\n this.reason = reason;\n this.url = url;\n this.status = options?.status;\n }\n}\n"],"mappings":";;;;;;;AAsBA,IAAa,YAAb,cAA+B,MAAM;CACnC;CACA;;CAEA;CAEA,YAAY,QAAyB,KAAa,SAAiB,SAA4B;EAC7F,MAAM,GAAGA,aAAAA,WAAW,GAAG,WAAW,EAAE,OAAO,SAAS,MAAM,CAAC;EAC3D,KAAK,OAAO;EACZ,KAAK,SAAS;EACd,KAAK,MAAM;EACX,KAAK,SAAS,SAAS;CACzB;AACF"}