Select Git revision
exception.service.ts

Etienne LOUPIAS authored
exception.service.ts 772 B
import { Injectable } from '@nestjs/common';
import { MailerService } from '../mailer/mailer.service';
@Injectable()
export class ExceptionService {
constructor(private readonly mailerService: MailerService) {}
handleUncaughtException(err: Error) {
console.log('Uncaught Exception :', err);
this.mailerService.send(
'eloupias@grandlyon.com',
'Uncaught Exception in NestJS Application',
`An uncaught exception occurred: ${JSON.stringify(err)}`
);
}
handleUnhandledRejection(reason: any) {
console.log('Unhandled Rejection:', reason);
this.mailerService.send(
'eloupias@grandlyon.com',
'Unhandled Promise Rejection in NestJS Application',
`An unhandled promise rejection occurred: ${reason}`
);
}
}