phero icon indicating copy to clipboard operation
phero copied to clipboard

Support reject(error) calls when analysing Errors

Open kamilafsar opened this issue 2 years ago • 0 comments

We parse/analyse all throw'n errors of the user. All errors are put in the SDK. One exception now is errors thrown with the Promise/reject syntax.

See recursivelyFindThrowStatements.test.ts

Here's how we could test for it:

test.skip("new Promise with reject", () => {
      const {
        statements: [funcOne],
        typeChecker,
      } = compileStatements(
        `
          async function funcOne(a: string): boolean {
            const x = await Promise.all([funcTwo()])
            return x[0];
          }
          async function funcTwo(): Promise<boolean> {
            return new Promise((resolve, reject) => {
              reject(new Error('error'))
            })
          }
        `,
      )

      expect(
        recursivelyFindThrowStatements(
          funcOne as ts.FunctionDeclaration,
          typeChecker,
        ),
      ).toHaveLength(1)
    })

kamilafsar avatar Sep 30 '22 11:09 kamilafsar