From 6ae35efb3ee9d069e0e62c24fa257bc49a38f0da Mon Sep 17 00:00:00 2001
From: parsa aghaei
Date: Sun, 16 Aug 2026 15:12:18 +0330
Subject: [PATCH] fix(filter): preserve custom Persian error messages in
HttpExceptionFilter
---
backend/src/common/filters/http-exception.filter.ts | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/backend/src/common/filters/http-exception.filter.ts b/backend/src/common/filters/http-exception.filter.ts
index 126086f0..ce88081f 100644
--- a/backend/src/common/filters/http-exception.filter.ts
+++ b/backend/src/common/filters/http-exception.filter.ts
@@ -92,19 +92,19 @@ export class CustomHttpExceptionFilter implements ExceptionFilter {
if (!msg) return 'خطای نامشخص رخ داده است.';
const lower = msg.toLowerCase();
- if (lower.includes('unauthorized') || status === 401) {
+ if (lower === 'unauthorized' || msg === 'Unauthorized') {
return 'شما دسترسی لازم برای این عملیات را ندارید. لطفاً ابتدا وارد حساب کاربری خود شوید.';
}
- if (lower.includes('forbidden') || status === 403) {
+ if (lower === 'forbidden' || msg === 'Forbidden') {
return 'دسترسی شما به این بخش یا منبع محدود شده است.';
}
- if (lower.includes('not found') || status === 404) {
+ if (lower === 'not found' || msg === 'Not Found') {
return 'مورد یا صفحه درخواستی یافت نشد.';
}
- if (status === 400) {
+ if (lower === 'bad request' || msg === 'Bad Request') {
return 'درخواست نامعتبر است. لطفاً پارامترهای ورودی را چک کنید.';
}
- if (status === 429) {
+ if (lower === 'too many requests' || msg === 'ThrottlerException: Too Many Requests') {
return 'تعداد درخواستهای شما بیش از حد مجاز است. لطفاً کمی صبر کرده و مجدداً تلاش کنید.';
}