@xbibzlibrary/tiktokscrap
Version:
Powerful TikTok Scraper and Downloader Library
78 lines (67 loc) • 2.13 kB
text/typescript
export class TikTokScrapError extends Error {
public code: string;
public statusCode?: number;
public details?: any;
constructor(message: string, code: string, statusCode?: number, details?: any) {
super(message);
this.name = 'TikTokScrapError';
this.code = code;
this.statusCode = statusCode;
this.details = details;
Error.captureStackTrace(this, this.constructor);
}
}
export class NetworkError extends TikTokScrapError {
constructor(message: string, statusCode?: number, details?: any) {
super(message, 'NETWORK_ERROR', statusCode, details);
this.name = 'NetworkError';
}
}
export class ParseError extends TikTokScrapError {
constructor(message: string, details?: any) {
super(message, 'PARSE_ERROR', undefined, details);
this.name = 'ParseError';
}
}
export class ValidationError extends TikTokScrapError {
constructor(message: string, details?: any) {
super(message, 'VALIDATION_ERROR', undefined, details);
this.name = 'ValidationError';
}
}
export class DownloadError extends TikTokScrapError {
constructor(message: string, details?: any) {
super(message, 'DOWNLOAD_ERROR', undefined, details);
this.name = 'DownloadError';
}
}
export class RateLimitError extends TikTokScrapError {
constructor(message: string, retryAfter?: number) {
super(message, 'RATE_LIMIT_ERROR', 429, { retryAfter });
this.name = 'RateLimitError';
}
}
export class AuthenticationError extends TikTokScrapError {
constructor(message: string) {
super(message, 'AUTHENTICATION_ERROR', 401);
this.name = 'AuthenticationError';
}
}
export class ForbiddenError extends TikTokScrapError {
constructor(message: string) {
super(message, 'FORBIDDEN_ERROR', 403);
this.name = 'ForbiddenError';
}
}
export class NotFoundError extends TikTokScrapError {
constructor(message: string) {
super(message, 'NOT_FOUND_ERROR', 404);
this.name = 'NotFoundError';
}
}
export class ServerError extends TikTokScrapError {
constructor(message: string) {
super(message, 'SERVER_ERROR', 500);
this.name = 'ServerError';
}
}