[ ] Regression
Let's say we got a consumer which applies middleware X for certain routes.. If we throw an exception in that middleware X (or pass the exception in the next/done function as new SampleException(...)), we receive a response of "[object Object]" which is really strange..
@nestjs/common 4.5.9, @nestjs/core 4.5.10, @nestjs/microservices 4.5.8, @nestjs/testing 4.5.5, @nestjs/websockets 4.5.8 => with these versions it works properly - instead of "[object Object]", the proper exception is returned
@Controller('api')
export class SampleController {
@Get('something')
getSomething() {}
}
const middleware = (req: Request, res: Response, next: NextFunction) => {
next(new UnauthorizedException('Invalid credentials'));
}
@Module({
controllers: [SampleController]
})
export class SampleModule {
configure(consumer: MiddlewaresConsumer) {
consumer.apply(middleware).forRoutes({path: 'api/getSomething', method: RequestMethod.Get})
}
}
Current behaviour:
GET /api/getSomething => [object Object] // [object Object] also gets logged in the server console
Expected behaviour (how it used to work):
GET /api/getSomething => {error: 'Unauthorized', message: 'Invalid credentials', status: 401}
the issue comes from the @nestjs/core package (I tested it by using an older @nestjs/core package and it worked)
I have this same problem
Fixed in v4.6.4
馃檪
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
Fixed in
v4.6.4
馃檪