mirror of
https://github.com/nestjs/nest.git
synced 2026-02-25 20:25:50 +00:00
15 lines
512 B
TypeScript
15 lines
512 B
TypeScript
import { RuntimeException } from './exceptions/runtime.exception';
|
|
import { Logger } from '@nestjs/common/services/logger.service';
|
|
|
|
export class ExceptionHandler {
|
|
private static readonly logger = new Logger(ExceptionHandler.name);
|
|
|
|
public handle(exception: RuntimeException | Error) {
|
|
if (!(exception instanceof RuntimeException)) {
|
|
ExceptionHandler.logger.error(exception.message, exception.stack);
|
|
return;
|
|
}
|
|
ExceptionHandler.logger.error(exception.what(), exception.stack);
|
|
}
|
|
}
|