nestia
nestia copied to clipboard
NestiaSwaggerComposer.compose(): Unable to find exception type.
Bug Report
Summary
Write a short summary of the bug in here.
- SDK Version: 4.5.2
- Expected behavior:
@TypedException<BadRequestException>({ status: 400, description: 'Invalid parameter provided.' })could find the exception type and generate Error case in Swagger document. - Actual behavior: This
@TypedExceptiontriggersNestiaSwaggerComposer.compose()erroring "Unable to find exception type".
Write detailed description in here.
Code occuring the bug
Referring to the case writing style from https://github.com/samchon/nestia/pull/548 , below is a shorter case that returns datetime where 400 is designated for invalid parameter request.
class HttpException extends Error {}
@Controller('get-datetime')
@ApiTags('Datetime')
export class DatetimeController {
/**
* /api/get-datetime
*/
constructor(
private readonly datetimeService: DatetimeService,
) { }
/**
* Retrieves the current date and time.
*
* @summary Retrieve Current Datetime
*
* @param timezone The timezone identifier (e.g., "UTC", "America/New_York").
* @returns The current date and time in the specified timezone, in ISO 8601 format.
*/
@Get()
@Header('Content-Type', 'text/plain')
@TypedException<HttpException>({
status: 400,
description: 'Invalid parameter provided.',
})
public getDateTime(
@Query('timezone') timezone?: string,
): string {
return this.datetimeService.getCurrentDatetime(timezone);
}
}
I would always get the following error log:
.../node_modules/@nestia/sdk/src/NestiaSwaggerComposer.ts:134
throw new Error(`Error on NestiaSwaggerComposer.compose():\n${messages}`);
^
Error: Error on NestiaSwaggerComposer.compose():
dist/apps/.../main.js - DatetimeController.getDateTime() from exception (status: 400):
- Unable to find exception type.
at report (.../node_modules/@nestia/sdk/src/NestiaSwaggerComposer.ts:134:9)
at analyze (.../node_modules/@nestia/sdk/src/NestiaSwaggerComposer.ts:55:13)
at .../node_modules/@nestia/sdk/src/NestiaSwaggerComposer.ts:30:15
at Generator.next (<anonymous>)
at fulfilled (.../node_modules/@nestia/sdk/lib/NestiaSwaggerComposer.js:5:58)
The same log would be triggered when I import NestJS's HttpExceptions:
@TypedException<BadRequestException>({
status: 400,
description: 'Invalid parameter provided.',
})