From b7fd893697341ca14d64f5872336278a66d2275d Mon Sep 17 00:00:00 2001 From: Egor Date: Tue, 20 Jan 2026 14:29:39 +0300 Subject: [PATCH] Update client.ts --- src/api/client.ts | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/api/client.ts b/src/api/client.ts index 808184c..b1d4714 100644 --- a/src/api/client.ts +++ b/src/api/client.ts @@ -87,6 +87,31 @@ apiClient.interceptors.request.use(async (config: InternalAxiosRequestConfig) => return config }) +// Custom error types for special handling +export interface MaintenanceError { + code: 'maintenance' + message: string + reason?: string +} + +export interface ChannelSubscriptionError { + code: 'channel_subscription_required' + message: string + channel_link?: string +} + +export function isMaintenanceError(error: unknown): error is { response: { status: 503, data: { detail: MaintenanceError } } } { + if (!error || typeof error !== 'object') return false + const err = error as AxiosError<{ detail: MaintenanceError }> + return err.response?.status === 503 && err.response?.data?.detail?.code === 'maintenance' +} + +export function isChannelSubscriptionError(error: unknown): error is { response: { status: 403, data: { detail: ChannelSubscriptionError } } } { + if (!error || typeof error !== 'object') return false + const err = error as AxiosError<{ detail: ChannelSubscriptionError }> + return err.response?.status === 403 && err.response?.data?.detail?.code === 'channel_subscription_required' +} + // Response interceptor - handle 401 as fallback apiClient.interceptors.response.use( (response) => response,