2026-05-13 16:57:07 +07:00
|
|
|
export class AppError extends Error {
|
2026-05-17 23:05:50 +07:00
|
|
|
public code: string;
|
|
|
|
|
public statusCode: number;
|
|
|
|
|
|
2026-05-13 16:57:07 +07:00
|
|
|
constructor(
|
|
|
|
|
message: string,
|
2026-05-17 23:05:50 +07:00
|
|
|
code: string,
|
|
|
|
|
statusCode: number = 500,
|
2026-05-13 16:57:07 +07:00
|
|
|
) {
|
|
|
|
|
super(message);
|
2026-05-17 23:05:50 +07:00
|
|
|
this.code = code;
|
|
|
|
|
this.statusCode = statusCode;
|
2026-05-13 16:57:07 +07:00
|
|
|
this.name = "AppError";
|
|
|
|
|
Error.captureStackTrace(this, this.constructor);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export class ConfigError extends AppError {
|
|
|
|
|
constructor(message: string) {
|
|
|
|
|
super(message, "CONFIG_ERROR", 500);
|
|
|
|
|
this.name = "ConfigError";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export class AudioError extends AppError {
|
|
|
|
|
constructor(message: string) {
|
|
|
|
|
super(message, "AUDIO_ERROR", 500);
|
|
|
|
|
this.name = "AudioError";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export class VoiceConnectionError extends AppError {
|
|
|
|
|
constructor(message: string) {
|
|
|
|
|
super(message, "VOICE_CONNECTION_ERROR", 500);
|
|
|
|
|
this.name = "VoiceConnectionError";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export class ValidationError extends AppError {
|
2026-05-17 23:05:50 +07:00
|
|
|
public details?: Record<string, string[]>;
|
|
|
|
|
|
2026-05-13 16:57:07 +07:00
|
|
|
constructor(
|
|
|
|
|
message: string,
|
2026-05-17 23:05:50 +07:00
|
|
|
details?: Record<string, string[]>,
|
2026-05-13 16:57:07 +07:00
|
|
|
) {
|
|
|
|
|
super(message, "VALIDATION_ERROR", 400);
|
2026-05-17 23:05:50 +07:00
|
|
|
this.details = details;
|
2026-05-13 16:57:07 +07:00
|
|
|
this.name = "ValidationError";
|
|
|
|
|
}
|
|
|
|
|
}
|