gather-ts
Version:
A powerful code analysis and packaging tool designed for creating AI-friendly code representations for javascript and typescript projects.
144 lines • 4.11 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ResourceLimitError = exports.TimeoutError = exports.CompilationError = exports.CacheError = exports.DependencyAnalysisError = exports.TokenizationError = exports.ConfigurationError = exports.FileSystemError = exports.ValidationError = exports.GatherTSError = void 0;
/**
* Base class for all gather-ts errors
*/
class GatherTSError extends Error {
constructor(message, details) {
super(message);
this.details = details;
this.timestamp = new Date().toISOString();
// Ensure proper prototype chain for instanceof checks
Object.setPrototypeOf(this, new.target.prototype);
}
toJSON() {
return {
name: this.name,
message: this.message,
details: this.details,
timestamp: this.timestamp,
stack: this.stack,
};
}
}
exports.GatherTSError = GatherTSError;
/**
* Input validation errors
*/
class ValidationError extends GatherTSError {
constructor(message, details) {
super(message, details);
this.name = "ValidationError";
}
}
exports.ValidationError = ValidationError;
/**
* File system operation errors
*/
class FileSystemError extends GatherTSError {
constructor(message, filePath, operation) {
super(message, { filePath, operation });
this.name = "FileSystemError";
}
get filePath() {
return this.details.filePath;
}
get operation() {
return this.details.operation;
}
}
exports.FileSystemError = FileSystemError;
/**
* Configuration related errors
*/
class ConfigurationError extends GatherTSError {
constructor(message, configPath) {
// Ensure configPath is non-null and non-undefined
if (!configPath) {
configPath = "unknown";
}
super(message, { configPath });
this.name = "ConfigurationError";
}
}
exports.ConfigurationError = ConfigurationError;
/**
* Token processing errors
*/
class TokenizationError extends GatherTSError {
constructor(message, filePath, operation, model) {
super(message, { filePath, operation, model });
this.name = "TokenizationError";
}
get filePath() {
return this.details.filePath;
}
get operation() {
return this.details.operation;
}
}
exports.TokenizationError = TokenizationError;
/**
* Dependency analysis errors
*/
class DependencyAnalysisError extends GatherTSError {
constructor(message, entryPoint, failedDependencies) {
super(message, { entryPoint, failedDependencies });
this.name = "DependencyAnalysisError";
}
get entryPoint() {
return this.details.entryPoint;
}
get failedDependencies() {
return this.details.failedDependencies;
}
}
exports.DependencyAnalysisError = DependencyAnalysisError;
/**
* Cache operation errors
*/
class CacheError extends GatherTSError {
constructor(message, operation, key) {
super(message, { operation, key });
this.name = "CacheError";
}
get operation() {
return this.details.operation;
}
}
exports.CacheError = CacheError;
/**
* Compilation process errors
*/
class CompilationError extends GatherTSError {
constructor(message, phase, details) {
super(message, { phase, ...details });
this.name = "CompilationError";
}
get phase() {
return this.details.phase;
}
}
exports.CompilationError = CompilationError;
/**
* Timeout errors
*/
class TimeoutError extends GatherTSError {
constructor(message, operation, timeout) {
super(message, { operation, timeout });
this.name = "TimeoutError";
}
}
exports.TimeoutError = TimeoutError;
/**
* Resource usage limit errors
*/
class ResourceLimitError extends GatherTSError {
constructor(message, resource, limit, actual) {
super(message, { resource, limit, actual });
this.name = "ResourceLimitError";
}
}
exports.ResourceLimitError = ResourceLimitError;
//# sourceMappingURL=index.js.map