Skip to content

Commit

Permalink
chore: give playwright errors more context
Browse files Browse the repository at this point in the history
  • Loading branch information
sneko committed Feb 26, 2024
1 parent 4667a8d commit 48fa7ad
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/features/website.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,21 @@ export async function getWebsiteData(browser: Browser, url: string, timeoutForDo
if (!!failure) {
// Mimic errors format we can have we other network libraries to factorize the handling logic since here it's just pure "useless" text (have a look at `src/utils/request.ts`)
if (failure.errorText.startsWith('net::')) {
const errorToThrow = new Error(`an error comes from the processing of Playwright`);
const errorToThrow = new Error(
`an error comes from the processing of Playwright for "${request.url()}" (which may just be an assert url when loading)`
);

errorToThrow.cause = {
code: failure.errorText,
};

errorWithDetailsIntoListener = errorToThrow;
} else errorWithDetailsIntoListener = new Error(`an error comes from the processing of Playwright: ${failure.errorText}`);
} else
errorWithDetailsIntoListener = new Error(
`an error comes from the processing of Playwright for "${request.url()}" (which may just be an assert url when loading): ${
failure.errorText
}`
);
}
});

Expand Down

0 comments on commit 48fa7ad

Please sign in to comment.