I want custom exception from FileInterceptor.
Here my lines of code:
@Post('single')
@UseInterceptors(
FileInterceptor('file', { limits: {
files: 1
}}),
)
async uploadFile(@UploadedFile() file, @GetUser('id') userId: number, @Body() dto) {
this.logger.log('Upload file');
file.createdBy = userId;
file.oldFileName = dto.oldFileName;
return this.client.send('upload_file', file);
}
I pass in body with file attribute, it is 1 array files (there are 2 files)
I got message:
{
"response": {
"statusCode": 400,
"message": "Too many files",
"error": "Bad Request"
},
"status": 400,
"message": "Too many files",
"name": "BadRequestException"
}
I want custom that message like to this:
{
"code": 400,
"message": "Too many files"
}
Please help me a solution. Thanks
you can try this to custom your error
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.