Skip to content

Commit

Permalink
Merge pull request #46 from Automattic/fix/throw-http-error-instead
Browse files Browse the repository at this point in the history
Fix throwing a generic error when an HTTP error occurred
  • Loading branch information
dilirity authored Jun 11, 2024
2 parents 8a9d1ee + b38e0a8 commit 3cd063b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/browser-interface-playwright.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Viewport } from './types';
import { BrowserInterface, BrowserRunnable, FetchOptions } from './browser-interface';
import { HttpError } from './errors';
import { BrowserContext, Page } from 'playwright-core';
import { objectPromiseAll } from './object-promise-all';

Expand Down Expand Up @@ -84,7 +85,7 @@ export class BrowserInterfacePlaywright extends BrowserInterface {

// Bail early if the page returned a non-200 status code.
if ( ! tab.statusCode || ! this.isOkStatus( tab.statusCode ) ) {
const error = new Error( `Page returned status code ${ tab.statusCode }` );
const error = new HttpError( { url: pageUrl, code: tab.statusCode } );
this.trackUrlError( pageUrl, error );
throw error;
}
Expand Down

0 comments on commit 3cd063b

Please sign in to comment.