UNPKG

@crosspost/scheduler-sdk

Version:

TypeScript SDK client for the Scheduler service

73 lines (72 loc) 1.98 kB
/** * Base error class for all Scheduler SDK errors */ export class SchedulerError extends Error { constructor(message) { super(message); this.name = 'SchedulerError'; Object.setPrototypeOf(this, SchedulerError.prototype); } } /** * Error thrown when a request to the Scheduler API fails */ export class ApiError extends SchedulerError { statusCode; data; constructor(message, statusCode, data) { super(message); this.name = 'ApiError'; this.statusCode = statusCode; this.data = data; Object.setPrototypeOf(this, ApiError.prototype); } } /** * Error thrown when a job validation fails */ export class ValidationError extends SchedulerError { errors; constructor(message, errors) { super(message); this.name = 'ValidationError'; this.errors = errors; Object.setPrototypeOf(this, ValidationError.prototype); } } /** * Error thrown when a job is not found */ export class JobNotFoundError extends SchedulerError { jobId; constructor(jobId) { super(`Job with ID ${jobId} not found`); this.name = 'JobNotFoundError'; this.jobId = jobId; Object.setPrototypeOf(this, JobNotFoundError.prototype); } } /** * Error thrown when a duplicate job is detected */ export class DuplicateJobError extends SchedulerError { jobName; constructor(jobName) { super(`Job with name "${jobName}" already exists`); this.name = 'DuplicateJobError'; this.jobName = jobName; Object.setPrototypeOf(this, DuplicateJobError.prototype); } } /** * Error thrown when there's a network issue */ export class NetworkError extends SchedulerError { originalError; constructor(message, originalError) { super(message); this.name = 'NetworkError'; this.originalError = originalError; Object.setPrototypeOf(this, NetworkError.prototype); } }