osrs-tools
Version:
A comprehensive TypeScript library for Old School RuneScape (OSRS) data and utilities, including quest data, skill requirements, and game item information
120 lines • 3.28 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ValidationError = exports.ApiError = exports.AccountError = exports.SkillError = exports.QuestError = exports.OsrsToolsError = void 0;
/**
* Base error class for OSRS Tools
* Contains additional context and helper methods
*/
class OsrsToolsError extends Error {
constructor(message) {
super(message);
this.name = 'OsrsToolsError';
this.timestamp = new Date().toISOString();
}
/**
* Get error details in a structured format
*/
toJSON() {
return {
name: this.name,
message: this.message,
timestamp: this.timestamp,
stack: this.stack,
};
}
}
exports.OsrsToolsError = OsrsToolsError;
/**
* Error thrown when quest-related operations fail
*/
class QuestError extends OsrsToolsError {
constructor(questName, message) {
super(`Quest error (${questName}): ${message}`);
this.name = 'QuestError';
this.questName = questName;
}
toJSON() {
return {
...super.toJSON(),
questName: this.questName,
};
}
}
exports.QuestError = QuestError;
/**
* Error thrown when skill-related operations fail
*/
class SkillError extends OsrsToolsError {
constructor(skillName, message, value) {
super(`Skill error (${skillName}): ${message}`);
this.name = 'SkillError';
this.skillName = skillName;
this.value = value;
}
toJSON() {
return {
...super.toJSON(),
skillName: this.skillName,
value: this.value,
};
}
}
exports.SkillError = SkillError;
/**
* Error thrown when account-related operations fail
*/
class AccountError extends OsrsToolsError {
constructor(message, accountName) {
super(`Account error${accountName ? ` (${accountName})` : ''}: ${message}`);
this.name = 'AccountError';
this.accountName = accountName;
}
toJSON() {
return {
...super.toJSON(),
accountName: this.accountName,
};
}
}
exports.AccountError = AccountError;
/**
* Error thrown when API-related operations fail
*/
class ApiError extends OsrsToolsError {
constructor(message, statusCode, endpoint) {
super(`API error: ${message}`);
this.name = 'ApiError';
this.statusCode = statusCode;
this.endpoint = endpoint;
}
toJSON() {
return {
...super.toJSON(),
statusCode: this.statusCode,
endpoint: this.endpoint,
};
}
}
exports.ApiError = ApiError;
/**
* Error thrown when validation fails
*/
class ValidationError extends OsrsToolsError {
constructor(field, value, message, constraints = {}) {
super(`Validation error (${field}): ${message}`);
this.name = 'ValidationError';
this.field = field;
this.value = value;
this.constraints = constraints;
}
toJSON() {
return {
...super.toJSON(),
field: this.field,
value: this.value,
constraints: this.constraints,
};
}
}
exports.ValidationError = ValidationError;
//# sourceMappingURL=index.js.map