fix: Response wrapping, error logging, and controller hardening (COA 3)
All checks were successful
Test Asgard Runner / test (push) Successful in 3s
All checks were successful
Test Asgard Runner / test (push) Successful in 3s
- HttpExceptionFilter: Log actual error details for non-HttpExceptions (was silently swallowing 500s)
- ServersService: Return null fields instead of 404 for new licenses without servers
- NotificationsController: Wrap config responses as { config } to match frontend expectations
- WebstoreController: Wrap config responses as { config } to match frontend expectations
- ChatController: Replace ParseIntPipe with manual parseInt (400 on missing optional param)
- WipesController: Same ParseIntPipe fix for history limit param
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -4,14 +4,18 @@ import {
|
||||
ArgumentsHost,
|
||||
HttpException,
|
||||
HttpStatus,
|
||||
Logger,
|
||||
} from '@nestjs/common';
|
||||
import { Response } from 'express';
|
||||
|
||||
@Catch()
|
||||
export class HttpExceptionFilter implements ExceptionFilter {
|
||||
private readonly logger = new Logger('ExceptionFilter');
|
||||
|
||||
catch(exception: unknown, host: ArgumentsHost) {
|
||||
const ctx = host.switchToHttp();
|
||||
const response = ctx.getResponse<Response>();
|
||||
const request = ctx.getRequest();
|
||||
|
||||
let status = HttpStatus.INTERNAL_SERVER_ERROR;
|
||||
let message = 'Internal server error';
|
||||
@@ -28,6 +32,13 @@ export class HttpExceptionFilter implements ExceptionFilter {
|
||||
message = obj.message[0] as string;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Log non-HttpException errors with full details
|
||||
const err = exception instanceof Error ? exception : new Error(String(exception));
|
||||
this.logger.error(
|
||||
`Unhandled exception on ${request.method} ${request.url}: ${err.message}`,
|
||||
err.stack,
|
||||
);
|
||||
}
|
||||
|
||||
response.status(status).json({ message });
|
||||
|
||||
Reference in New Issue
Block a user