Effect CommunityEC
Effect Community3y ago
4 replies
iamK

Using runPromise throws FiberFailure

why is the error not an instance of BadRequestException and how to tackle this ?

async create(@Body() createArticleDto: CreateArticleDto) {
    const program = pipe(
      createArticleDto,
      dtoToEntity,
      createOne,
      Effect.catchAll(() => Effect.fail(new BadRequestException())),
    );

    try {
      await this.runtime.runPromise(program);
    } catch (err: any) {
      console.log(err.name); // BadRequestException
      const isBadRequest = err instanceof BadRequestException; // false
    }
  }
Was this page helpful?