UNPKG

@xcrap/core

Version:

Xcrap Core is the core package of the Xcrap framework for web scraping, offering tools such as HttpClient, BaseClient, Randomizer, Rotator, and support for proxies and pagination.

90 lines (89 loc) 3.3 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.InvalidMarkdownBody = exports.InvalidHtmlBody = exports.InvalidJsonBody = exports.InvalidStatusCodeError = exports.EmptyArrayError = exports.PageOutOfRangeError = exports.InvalidPageError = exports.InvalidUrlError = exports.StaticPaginatorError = exports.InvalidPageValueError = exports.PageParsingFailureError = exports.TrackingError = void 0; class TrackingError extends Error { constructor(message) { super(message); this.name = "TrackingError"; } } exports.TrackingError = TrackingError; class PageParsingFailureError extends TrackingError { constructor() { super("Failed to parse current or last page from the response."); this.name = "PageParsingFailureError"; } } exports.PageParsingFailureError = PageParsingFailureError; class InvalidPageValueError extends TrackingError { constructor() { super("Parsed page values are not valid numbers."); this.name = "InvalidPageValueError"; } } exports.InvalidPageValueError = InvalidPageValueError; class StaticPaginatorError extends Error { constructor(message) { super(message); this.name = "StaticPaginatorError"; } } exports.StaticPaginatorError = StaticPaginatorError; class InvalidUrlError extends StaticPaginatorError { constructor(url) { super(`The provided URL does not contain the string {page}: ${url}`); this.name = "InvalidUrlError"; } } exports.InvalidUrlError = InvalidUrlError; class InvalidPageError extends StaticPaginatorError { constructor(page, minPage, lastPage) { super(`The given page ${page} is outside the allowed range [${minPage}, ${lastPage}]`); this.name = "InvalidPageError"; } } exports.InvalidPageError = InvalidPageError; class PageOutOfRangeError extends StaticPaginatorError { constructor(page, minPage, lastPage) { super(`Page ${page} is outside the allowed range [${minPage}, ${lastPage}]`); this.name = "PageOutOfRangeError"; } } exports.PageOutOfRangeError = PageOutOfRangeError; class EmptyArrayError extends Error { constructor(name) { super(`${name} cannot receive empty arrays`); this.name = "EmptyArrayError"; } } exports.EmptyArrayError = EmptyArrayError; class InvalidStatusCodeError extends Error { constructor(statusCode, url) { super(`Request failed with invalid status code: ${statusCode}`); this.statusCode = statusCode; this.url = url; Object.setPrototypeOf(this, InvalidStatusCodeError.prototype); } } exports.InvalidStatusCodeError = InvalidStatusCodeError; class InvalidJsonBody extends Error { constructor(message = "Invalid JSON body.") { super(message); this.name = "InvalidJsonBody"; } } exports.InvalidJsonBody = InvalidJsonBody; class InvalidHtmlBody extends Error { constructor(message = "Invalid HTML body.") { super(message); this.name = "InvalidHtmlBody"; } } exports.InvalidHtmlBody = InvalidHtmlBody; class InvalidMarkdownBody extends Error { constructor(message = "Invalid Markdown body.") { super(message); this.name = "InvalidMarkdownBody"; } } exports.InvalidMarkdownBody = InvalidMarkdownBody;