11import { isUndefined , toNumber , uniq } from 'lodash' ;
22import {
3- BadRequestException ,
43 ConflictException ,
5- HttpException ,
64 Injectable ,
75 Logger ,
86} from '@nestjs/common' ;
97import ERROR_MESSAGES from 'src/constants/error-messages' ;
10- import { catchAclError } from 'src/utils' ;
8+ import { catchRedisSearchError } from 'src/utils' ;
119import { ClientMetadata } from 'src/common/models' ;
1210import {
1311 CreateRedisearchIndexDto ,
@@ -17,9 +15,8 @@ import {
1715 SearchRedisearchDto ,
1816} from 'src/modules/browser/redisearch/dto' ;
1917import { GetKeysWithDetailsResponse } from 'src/modules/browser/keys/dto' ;
20- import { DEFAULT_MATCH , RedisErrorCodes } from 'src/constants' ;
18+ import { DEFAULT_MATCH } from 'src/constants' ;
2119import { plainToInstance } from 'class-transformer' ;
22- import { numberWithSpaces } from 'src/utils/base.helper' ;
2320import { BrowserHistoryMode , RedisString } from 'src/common/constants' ;
2421import { CreateBrowserHistoryDto } from 'src/modules/browser/browser-history/dto' ;
2522import { BrowserHistoryService } from 'src/modules/browser/browser-history/browser-history.service' ;
@@ -68,7 +65,8 @@ export class RedisearchService {
6865 } ) ;
6966 } catch ( e ) {
7067 this . logger . error ( 'Failed to get redisearch indexes' , e , clientMetadata ) ;
71- throw catchAclError ( e ) ;
68+
69+ throw catchRedisSearchError ( e ) ;
7270 }
7371 }
7472
@@ -142,7 +140,8 @@ export class RedisearchService {
142140 return undefined ;
143141 } catch ( e ) {
144142 this . logger . error ( 'Failed to create redisearch index' , e , clientMetadata ) ;
145- throw catchAclError ( e ) ;
143+
144+ throw catchRedisSearchError ( e ) ;
146145 }
147146 }
148147
@@ -174,7 +173,8 @@ export class RedisearchService {
174173 return plainToInstance ( IndexInfoDto , convertIndexInfoReply ( infoReply ) ) ;
175174 } catch ( e ) {
176175 this . logger . error ( 'Failed to get index info' , e , clientMetadata ) ;
177- throw catchAclError ( e ) ;
176+
177+ throw catchRedisSearchError ( e ) ;
178178 }
179179 }
180180
@@ -264,15 +264,8 @@ export class RedisearchService {
264264 e ,
265265 clientMetadata ,
266266 ) ;
267- if ( e instanceof HttpException ) {
268- throw e ;
269- }
270- if ( e . message ?. includes ( RedisErrorCodes . RedisearchLimit ) ) {
271- throw new BadRequestException (
272- ERROR_MESSAGES . INCREASE_MINIMUM_LIMIT ( numberWithSpaces ( dto . limit ) ) ,
273- ) ;
274- }
275- throw catchAclError ( e ) ;
267+
268+ throw catchRedisSearchError ( e , { searchLimit : dto . limit } ) ;
276269 }
277270 }
278271
0 commit comments