@texagon/nestjs-health
Version:
A comprehensive health monitoring package for NestJS applications with metrics and Kubernetes-ready health checks
38 lines (33 loc) • 1.15 kB
text/typescript
import {
Controller,
Get,
InternalServerErrorException,
Logger,
} from "@nestjs/common";
import { ApiTags, ApiOperation, ApiResponse } from "@nestjs/swagger";
export class TestErrorController {
private readonly logger = new Logger(TestErrorController.name);
triggerError(): never {
this.logger.debug("About to throw a test error");
this.logger.error(
"Test error triggered",
new Error("This is a test error").stack,
);
throw new InternalServerErrorException("This is a test error");
}
testLogLevels() {
this.logger.debug("This is a debug message");
this.logger.log("This is an info message");
this.logger.warn("This is a warning message");
this.logger.error("This is an error message");
return { message: "All log levels tested" };
}
}