This commit is contained in:
hamid zarghami
2026-01-27 12:23:27 +03:30
parent 1f33fa7a7f
commit 9785078c8f
19 changed files with 832 additions and 7 deletions
+20
View File
@@ -45,3 +45,23 @@ export const NumberFormat = (num?: number): string => {
if (!num) return "0";
return num.toLocaleString("fa-IR");
};
export interface IGeneralError {
status: number;
success: boolean;
error: {
message: string[];
};
}
export const extractErrorMessage = (
error: Error | unknown,
fallbackMessage: string = "خطایی رخ داده است",
): string => {
try {
const axiosError = error as { response?: { data: IGeneralError } };
return axiosError?.response?.data?.error?.message?.[0] || fallbackMessage;
} catch {
return fallbackMessage;
}
};