Add Custom Handlers
import { HttpException, ImATeapotException } from '@nestjs/common';
import { PrismaClientKnownRequestError } from '@prisma/client/runtime/library';
import { PrismaErrorHandler } from '@tradinos/cms-backend-error-handling';
export class MyAwesomePrismaErrorHandler implements PrismaErrorHandler {
handle(error: PrismaClientKnownRequestError): HttpException {
return new ImATeapotException();
}
}import { HttpException, ImATeapotException } from '@nestjs/common';
import { PrismaClientKnownRequestError } from '@prisma/client/runtime/library';
import { RegisterPrismaErrorHandler, PrismaErrorHandler } from '@tradinos/cms-backend-error-handling';
@RegisterPrismaErrorHandler({ codes: ['Some Code'] })
export class MyAwesomePrismaErrorHandler implements PrismaErrorHandler {
handle(error: PrismaClientKnownRequestError): HttpException {
return new ImATeapotException();
}
}Last updated