@akomalabs/kemono
Version:
A production-grade TypeScript API wrapper for the Kemono/Coomer platforms
55 lines • 1.67 kB
JavaScript
/**
* Custom error class for Kemono API errors
*/
export class KemonoApiError extends Error {
status;
code;
constructor(message, status, code = 'KEMONO_API_ERROR') {
super(message);
this.name = 'KemonoApiError';
this.status = status;
this.code = code;
Object.setPrototypeOf(this, KemonoApiError.prototype);
}
}
/**
* Error thrown when rate limit is exceeded
*/
export class RateLimitError extends KemonoApiError {
constructor(message = 'Rate limit exceeded') {
super(message, 429, 'RATE_LIMIT_EXCEEDED');
this.name = 'RateLimitError';
Object.setPrototypeOf(this, RateLimitError.prototype);
}
}
/**
* Error thrown when authentication fails
*/
export class AuthenticationError extends KemonoApiError {
constructor(message = 'Authentication failed') {
super(message, 401, 'AUTHENTICATION_FAILED');
this.name = 'AuthenticationError';
Object.setPrototypeOf(this, AuthenticationError.prototype);
}
}
/**
* Error thrown when a resource is not found
*/
export class NotFoundError extends KemonoApiError {
constructor(message = 'Resource not found') {
super(message, 404, 'NOT_FOUND');
this.name = 'NotFoundError';
Object.setPrototypeOf(this, NotFoundError.prototype);
}
}
/**
* Error thrown when validation fails
*/
export class ValidationError extends KemonoApiError {
constructor(message = 'Validation failed') {
super(message, 400, 'VALIDATION_FAILED');
this.name = 'ValidationError';
Object.setPrototypeOf(this, ValidationError.prototype);
}
}
//# sourceMappingURL=api-error.js.map