mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
25 lines
804 B
TypeScript
25 lines
804 B
TypeScript
import type { ProviderId } from './types';
|
|||
|
|
|
||
|
|
export interface ProviderAttempt {
|
||
|
|
provider: ProviderId;
|
||
|
|
success: boolean;
|
||
|
|
error?: string;
|
||
|
|
}
|
||
|
|
|
||
|
|
export type TranslateFn = (key: string) => string;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Formats aggregated error message when all providers fail (random mode).
|
||
|
|
*/
|
||
|
|
export function formatAggregatedError(attempts: ProviderAttempt[], t: TranslateFn): string {
|
||
|
|
const details = attempts.map((a) => `${a.provider}: ${a.error ?? 'unknown'}`).join('; ');
|
||
|
|
return `${t('upload_failed')}. ${t('upload_failed_all_providers')}: ${details}`;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Formats error for preferred mode with actionable guidance.
|
||
|
|
*/
|
||
|
|
export function formatPreferredModeError(errorMessage: string, t: TranslateFn): string {
|
||
|
|
return `${t('upload_failed')}: ${errorMessage}. ${t('upload_failed_preferred_guidance')}`;
|
||
|
|
}
|