{"id":"2f20e1f61c830b80","repo":"nestjs/nest","slug":"invalid-exception-filters-usefilters-2f20e1","errorCode":null,"errorMessage":"Invalid exception filters (@UseFilters()).","messagePattern":"Invalid exception filters \\(@UseFilters\\(\\)\\)\\.","errorType":"exception","errorClass":"InvalidExceptionFilterException","httpStatus":null,"severity":"error","filePath":"packages/websockets/exceptions/ws-exceptions-handler.ts","lineNumber":25,"sourceCode":"import { BaseWsExceptionFilter } from './base-ws-exception-filter';\n\n/**\n * @publicApi\n */\nexport class WsExceptionsHandler extends BaseWsExceptionFilter {\n  private filters: ExceptionFilterMetadata[] = [];\n\n  public handle(exception: Error | WsException, host: ArgumentsHost) {\n    const client = host.switchToWs().getClient();\n    if (this.invokeCustomFilters(exception, host) || !client.emit) {\n      return;\n    }\n    super.catch(exception, host);\n  }\n\n  public setCustomFilters(filters: ExceptionFilterMetadata[]) {\n    if (!Array.isArray(filters)) {\n      throw new InvalidExceptionFilterException();\n    }\n    this.filters = filters;\n  }\n\n  public invokeCustomFilters<T = any>(\n    exception: T,\n    args: ArgumentsHost,\n  ): boolean {\n    if (isEmpty(this.filters)) return false;\n\n    const filter = selectExceptionFilterMetadata(this.filters, exception);\n    filter && filter.func(exception, args);\n    return !!filter;\n  }\n}\n","sourceCodeStart":7,"sourceCodeEnd":41,"githubUrl":"https://github.com/nestjs/nest/blob/6ec0e2783d15290732447f304d8549b591b9749e/packages/websockets/exceptions/ws-exceptions-handler.ts#L7-L41","documentation":"Error \"Invalid exception filters (@UseFilters()).\" thrown in nestjs/nest.","triggerScenarios":"Thrown at packages/websockets/exceptions/ws-exceptions-handler.ts:25 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass valid exception filter classes or instances to @UseFilters(); each filter must implement ExceptionFilter (have a catch method).","Do not pass plain objects, undefined, or non-filter values to @UseFilters().","Ensure the filter class is decorated with @Catch() and properly imported."],"exampleFix":"@Catch(WsException)\nexport class WsFilter implements ExceptionFilter {\n  catch(exception: WsException, host: ArgumentsHost) { /* handle */ }\n}\n@UseFilters(WsFilter)\n@WebSocketGateway()\nexport class EventsGateway {}","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"analyzedSha":"6ec0e2783d15290732447f304d8549b591b9749e","analyzedAt":"2026-08-03T17:42:23.673Z","schemaVersion":2}