I dont have any code but i tried that few days ago like what if i have extended the request interface of express for custom properties on request object and now i want to use those properties while i am handling error via a nest error handle which looks like this
import { ExceptionFilter, Catch, ArgumentsHost, HttpException } from '@nestjs/common';
import { Request, Response } from 'express';
@Catch(HttpException)
export class HttpExceptionFilter implements ExceptionFilter {
catch(exception: HttpException, host: ArgumentsHost) {
const ctx = host.switchToHttp();
const response = ctx.getResponse<Response>();
const request = ctx.getRequest<Request>();
const status = exception.getStatus();
response
.status(status)
.json({
statusCode: status,
timestamp: new Date().toISOString(),
path: request.url,
});
}
}
The ctx response and request i am getting will not include my custom properties right bc it is referring to the express Request interface