httpsms-gateway / web /app /utils /api-error.ts
ML Intern deploy
Deploy httpSMS gateway to Hugging Face Spaces (Docker SDK): nginx :7860 -> Go API :8000, Nuxt SPA, Android APK, bootstrap-mode entrypoint
83a59ca
Raw History Blame
497 Bytes
/**
* Shape of the error object thrown by ofetch/$fetch for failed API requests.
*/
export interface ApiError {
status?: number
data?: {
message?: string
data?: Record<string, string[]>
}
}
export function toApiError(error: unknown): ApiError {
if (error !== null && typeof error === 'object') {
return error as ApiError
}
return {}
}
export function getApiErrorMessage(error: unknown, fallback: string): string {
return toApiError(error).data?.message ?? fallback
}