Skip to content

Commit beecac0

Browse files
docs: use exception factory for ws and rpc (validation pipe)
1 parent b1a9402 commit beecac0

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

content/microservices/pipes.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ The following example uses a manually instantiated method-scoped pipe. Just as w
1010

1111
```typescript
1212
@@filename()
13-
@UsePipes(new ValidationPipe())
13+
@UsePipes(new ValidationPipe({ exceptionFactory: (errors) => new RpcException(errors) }))
1414
@MessagePattern({ cmd: 'sum' })
1515
accumulate(data: number[]): number {
1616
return (data || []).reduce((a, b) => a + b);
1717
}
1818
@@switch
19-
@UsePipes(new ValidationPipe())
19+
@UsePipes(new ValidationPipe({ exceptionFactory: (errors) => new RpcException(errors) }))
2020
@MessagePattern({ cmd: 'sum' })
2121
accumulate(data) {
2222
return (data || []).reduce((a, b) => a + b);

content/websockets/pipes.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ The following example uses a manually instantiated method-scoped pipe. Just as w
1010

1111
```typescript
1212
@@filename()
13-
@UsePipes(new ValidationPipe())
13+
@UsePipes(new ValidationPipe({ exceptionFactory: (errors) => new WsException(errors) }))
1414
@SubscribeMessage('events')
1515
handleEvent(client: Client, data: unknown): WsResponse<unknown> {
1616
const event = 'events';
1717
return { event, data };
1818
}
1919
@@switch
20-
@UsePipes(new ValidationPipe())
20+
@UsePipes(new ValidationPipe({ exceptionFactory: (errors) => new WsException(errors) }))
2121
@SubscribeMessage('events')
2222
handleEvent(client, data) {
2323
const event = 'events';

0 commit comments

Comments
 (0)