Skip to content

Commit

Permalink
docs: use exception factory for ws and rpc (validation pipe)
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilmysliwiec committed Nov 21, 2024
1 parent b1a9402 commit beecac0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions content/microservices/pipes.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ The following example uses a manually instantiated method-scoped pipe. Just as w

```typescript
@@filename()
@UsePipes(new ValidationPipe())
@UsePipes(new ValidationPipe({ exceptionFactory: (errors) => new RpcException(errors) }))
@MessagePattern({ cmd: 'sum' })
accumulate(data: number[]): number {
return (data || []).reduce((a, b) => a + b);
}
@@switch
@UsePipes(new ValidationPipe())
@UsePipes(new ValidationPipe({ exceptionFactory: (errors) => new RpcException(errors) }))
@MessagePattern({ cmd: 'sum' })
accumulate(data) {
return (data || []).reduce((a, b) => a + b);
Expand Down
4 changes: 2 additions & 2 deletions content/websockets/pipes.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ The following example uses a manually instantiated method-scoped pipe. Just as w

```typescript
@@filename()
@UsePipes(new ValidationPipe())
@UsePipes(new ValidationPipe({ exceptionFactory: (errors) => new WsException(errors) }))
@SubscribeMessage('events')
handleEvent(client: Client, data: unknown): WsResponse<unknown> {
const event = 'events';
return { event, data };
}
@@switch
@UsePipes(new ValidationPipe())
@UsePipes(new ValidationPipe({ exceptionFactory: (errors) => new WsException(errors) }))
@SubscribeMessage('events')
handleEvent(client, data) {
const event = 'events';
Expand Down

0 comments on commit beecac0

Please sign in to comment.