upgrade repositories

This commit is contained in:
sbriat
2023-07-13 08:58:58 +02:00
parent f111563137
commit 0ccaafc5e0
11 changed files with 532 additions and 22 deletions

View File

@@ -4,7 +4,7 @@ import {
RpcExceptionCode,
RpcValidationPipe,
} from '@mobicoop/ddd-library';
import { Controller, UsePipes } from '@nestjs/common';
import { Controller, UnauthorizedException, UsePipes } from '@nestjs/common';
import { CommandBus } from '@nestjs/cqrs';
import { GrpcMethod, RpcException } from '@nestjs/microservices';
import { DeleteUsernameRequestDto } from './dtos/delete-username.request.dto';
@@ -25,12 +25,16 @@ export class DeleteUsernameGrpcController {
try {
await this.commandBus.execute(new DeleteUsernameCommand(data));
} catch (error: any) {
if (error instanceof UnauthorizedException)
throw new RpcException({
code: RpcExceptionCode.PERMISSION_DENIED,
message: error.message,
});
if (error instanceof NotFoundException)
throw new RpcException({
code: RpcExceptionCode.NOT_FOUND,
message: error.message,
});
if (error instanceof DatabaseErrorException)
throw new RpcException({
code: RpcExceptionCode.INTERNAL,