mirror of
https://github.com/andy-stack/vaultkeeper-ai.git
synced 2026-07-22 16:30:27 +00:00
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).
41 lines
No EOL
1.1 KiB
TypeScript
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);
|
|
}
|
|
|
|
} |