我有一个在 app 模块中注册的动态模块。它有一个名为 PermissionsUtil 的实用程序类,它在其中处理某些验证逻辑并抛出 UnauthorizedException,但我总是在接收端收到 InternalServerErrorException。
内部动态模块
权限.util.ts
@Injectable()
class PermissionsUtil {
someFunction() {
...performs validation logic here
if(badCase) {
throw new UnauthorizedException('Insufficient Permission');
}
return true;
}
}
内部应用模块
一些.controller.ts
@Controller()
class SomeController {
constructor(
private readonly permissionsUtil: PermissionsUtil,
) {}
@Patch()
someFunction() {
await this.permissionsUtil.someFunction(); //here it should throw unAuthorizedException but throws default InternalServerErrorException
return true;
}
}
注意:所有模块、控制器和服务注册都是正确的并且按预期工作。