fix : return orginal error

This commit is contained in:
2025-12-28 08:57:39 +03:30
parent 652780c238
commit ca53552511
2 changed files with 20 additions and 96 deletions
@@ -66,6 +66,12 @@ export class RestaurantService {
);
return data;
} catch (error: unknown) {
// Return validation errors or other error types from external API
if (error instanceof AxiosError && error.response?.data) {
this.logger.error(`External API error response:`, error.response.data);
return error.response.data;
}
this.logger.error(`Error fetching restaurants: ${error instanceof Error ? error.message : "Unknown error"}`);
throw error;
}
@@ -131,6 +137,12 @@ export class RestaurantService {
);
return data;
} catch (error: unknown) {
// Return validation errors or other error types from external API
if (error instanceof AxiosError && error.response?.data) {
this.logger.error(`External API error response:`, error.response.data);
return error.response.data;
}
this.logger.error(`Error getting restaurant subscription: ${error instanceof Error ? error.message : "Unknown error"}`);
throw error;
}
@@ -146,13 +158,19 @@ export class RestaurantService {
.pipe(
catchError((err: AxiosError) => {
this.logger.error("error in getting SMS count by restaurant", err);
throw new BadRequestException("Failed to fetch SMS count data");
return throwError(() => err);
}),
),
);
return data;
} catch (error) {
} catch (error: unknown) {
// Return validation errors or other error types from external API
if (error instanceof AxiosError && error.response?.data) {
this.logger.error(`External API error response:`, error.response.data);
return error.response.data;
}
this.logger.error("error in getSmsCountByRestaurant", error);
throw error;
}