samchon / nestia

NestJS Helper Libraries + TypeScript OpenAPI generator
https://nestia.io/
MIT License
1.85k stars 95 forks source link

TypedException error occurs when using applyDecorators after upgrading from version 3.2.1 to 3.12.0 #1005

Open oz-k opened 2 months ago

oz-k commented 2 months ago
@Controller("bbs/articles/:section")
export class BbsArticlesController {
  @core.TypedRoute.Patch()
  @TypedException<UnauthorizedException>({
    status: 401,
    description: "Unauthorized",
  })
  public index(
    @core.TypedParam("section") section: string,
    @core.TypedBody() input: IBbsArticle.IRequest,
  ): Promise<IPage<IBbsArticle.ISummary>> {
    return BbsArticleProvider.index(section, input);
  }
}

There is no issue when used as shown in the code above.

const appliedDecorators = applyDecorators(
  TypedException<UnauthorizedException>({
    status: 401,
    description: "Unauthorized",
  }),
);

@Controller("bbs/articles/:section")
export class BbsArticlesController {
  @core.TypedRoute.Patch()
  @appliedDecorators
  public index(
    @core.TypedParam("section") section: string,
    @core.TypedBody() input: IBbsArticle.IRequest,
  ): Promise<IPage<IBbsArticle.ISummary>> {
    return BbsArticleProvider.index(section, input);
  }
}

However, when using applyDecorators, the error ‘Unable to find Exception type.’ occurs.

$ rimraf src/api/functional && nestia sdk
-----------------------------------------------------------
 Nestia SDK Generator
-----------------------------------------------------------
[Nest] 65460  - 08/30/2024, 4:26:26 PM     LOG [NestFactory] Starting Nest application...
[Nest] 65460  - 08/30/2024, 4:26:26 PM     LOG [InstanceLoader] MyModule dependencies initialized +4ms
[Nest] 65460  - 08/30/2024, 4:26:26 PM     LOG [InstanceLoader] BbsArticleModule dependencies initialized +1ms
Analyzing reflections

-----------------------------------------------------------
 Nestia Error Report
-----------------------------------------------------------
src/controllers/bbs/BbsArticlesController.ts - BbsArticlesController.index() from exception (status: 401):
  - Unable to find exception type.
✨  Done in 2.00s.
samchon commented 2 months ago

I'm sorry but no way to revive it now.

Please use @TypedException() independently please.