Error handle for prisma.io with NestJs / Captura de erros do prisma.io com NestJS
Using npm:
$ npm i http-exception-filter-prisma-nestjs
import { HttpExceptionFilter } from 'http-exception-filter-prisma-nestjs';
Add the code inside your Bootstrap function / Adicione o codigo dentro de sua função Bootstrap
app.useGlobalFilters(new HttpExceptionFilter());
example / exemplo
async function bootstrap() {
const app = await NestFactory.create(AppModule);
app.useGlobalFilters(new HttpExceptionFilter());
app.enableShutdownHooks();
await app.listen(3001);
}
bootstrap();
import { HttpExceptionFilter } from 'http-exception-filter-prisma-nestjs';
add the snippet below in providers / adicione o trecho abaixo em providers
PrismaService,
{
provide: APP_FILTER,
useClass: HttpExceptionFilter,
},
example of use / exemplo de uso
@Module({
imports: [],
controllers: [],
providers: [
PrismaService,
{
provide: APP_FILTER,
useClass: HttpExceptionFilter,
},
],
})
export class AppModule {}