@emmahyde/thinking-patterns
Version:
MCP server combining systematic thinking, mental models, debugging approaches, and stochastic algorithms for comprehensive cognitive pattern support
65 lines (64 loc) • 1.78 kB
JavaScript
export class ValidationError extends Error {
constructor(message, details) {
super(message);
this.name = 'ValidationError';
this.code = 'VALIDATION_ERROR';
this.details = details === null ? null : (details ? { ...details } : undefined); // Preserve null vs undefined
}
toJSON() {
return {
message: this.message,
name: this.name,
code: this.code,
details: this.details
};
}
}
export class StateError extends Error {
constructor(message, sessionId) {
super(message);
this.name = 'StateError';
this.code = 'STATE_ERROR';
this.sessionId = sessionId;
}
toJSON() {
return {
message: this.message,
name: this.name,
code: this.code,
sessionId: this.sessionId
};
}
}
export class SecurityError extends Error {
constructor(message, severity = 'medium') {
super(message);
this.name = 'SecurityError';
this.code = 'SECURITY_ERROR';
this.severity = severity;
}
toJSON() {
return {
message: this.message,
name: this.name,
code: this.code,
severity: this.severity
};
}
}
export class ProcessingError extends Error {
constructor(message, context) {
super(message);
this.name = 'ProcessingError';
this.code = 'PROCESSING_ERROR';
this.context = context === null ? null : (context ? { ...context } : undefined); // Preserve null vs undefined
}
toJSON() {
return {
message: this.message,
name: this.name,
code: this.code,
context: this.context
};
}
}