phero
phero copied to clipboard
Support reject(error) calls when analysing Errors
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)
})