andy-stack_vaultkeeper-ai/Helpers/Exception.ts
Andrew Beal 3e013f6c9f refactor: migrate from flag-based content types to typed properties
Replace boolean flags (isFunctionCall, isFunctionCallResponse,
isProviderSpecificContent) with explicit typed properties (functionCall,
functionResponse, attachments) in ConversationContent. Introduce Attachment
class and BaseAIFileService. Update all AI providers (Claude, Gemini, OpenAI)
to use new attachment-based binary file handling with proper error handling,
retry logic, and AbortService integration.
Implement new Files API service for all providers (not yet integrated).
2025-12-19 12:30:51 +00:00

41 lines
No EOL
1.1 KiB
TypeScript

import { Environment } from "Enums/Environment";
export abstract class Exception {
public static throw(error: unknown): never {
this.log(error);
throw error;
}
public static new(error: unknown): Error {
return error instanceof Error ? error : new Error(this.messageFrom(error));
}
public static log(error: unknown) {
if (process.env.NODE_ENV === Environment.DEV) {
const e: Error = this.new(error);
console.error(e.message, e);
}
}
public static warn(error: unknown) {
if (process.env.NODE_ENV === Environment.DEV) {
const e: Error = this.new(error);
console.warn(e.message, e);
}
}
public static messageFrom(error: unknown): string {
if (error instanceof Error) {
return error.message;
}
if (typeof error === "string") {
return error;
}
if (error && typeof error === "object" && "message" in error) {
return String(error.message);
}
return String(error);
}
}