forked from Tadrisino/MathApp_frontend
Users never see error text: offline/slow wording in app and web; technical details are never shown
friendlyError now shows a server detail only when it is Persian prose (no 'خطای 404', no DRF English defaults); network errors say 'اینترنت قطع است' (navigator offline) or 'اینترنت کند است' (timeout). The native connecting screen picks the same two wordings from ConnectivityManager (ACCESS_NETWORK_STATE). Debug build compiles; not run on a device. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -21,6 +21,8 @@ export class ApiError extends Error {
|
||||
readonly status: number,
|
||||
readonly detail: string,
|
||||
readonly body: Record<string, unknown> = {},
|
||||
/** فقط برای status 0: درخواست بهخاطرِ timeout قطع شد (اینترنت کند)، نه رسیدننداشتن (اینترنت قطع). */
|
||||
readonly timedOut = false,
|
||||
) {
|
||||
super(detail);
|
||||
this.name = 'ApiError';
|
||||
@@ -248,7 +250,7 @@ export function createHttpClient(options: HttpClientOptions) {
|
||||
} catch (err) {
|
||||
if (opts.signal?.aborted) throw err;
|
||||
const timedOut = err instanceof DOMException && (err.name === 'TimeoutError' || err.name === 'AbortError');
|
||||
throw new ApiError(0, timedOut ? 'زمانِ درخواست تمام شد' : 'ارتباط با سرور برقرار نشد');
|
||||
throw new ApiError(0, timedOut ? 'زمانِ درخواست تمام شد' : 'ارتباط با سرور برقرار نشد', {}, timedOut);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user