---
title: "Errors"
description: "Most failures are a typed BrowserError. Which class means fix the call and which means wait and which means try another provider"
canonical_url: "https://browsers.agntn.dev/guide/errors"
---
# Errors

> Most failures are a typed BrowserError. Which class means fix the call and which means wait and which means try another provider

Failures from a vendor go through `normalizeError`, so a 401 from Steel and a 401 from Cloudflare are the same `AuthError`. The package's own guards throw `BrowserError` subclasses too, down to a Playwright screenshot without a session. Catch the class, not the message. Keep a last branch that rethrows anyway, since a bug still throws whatever JavaScript throws.

```ts
import { AuthError, RateLimitError, create } from "@agntn/browsers";

try {
  await (await create("steel")).scrape("https://example.com");
} catch (error) {
  if (error instanceof RateLimitError) {
    await new Promise((resolve) => setTimeout(resolve, error.retryAfter * 1000));
  }
  else if (error instanceof AuthError) console.error(`fix the key for ${error.provider}`);
  else throw error;
}
```

## Fix the call

<table>
<thead>
  <tr>
    <th>
      Class
    </th>
    
    <th>
      When
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        UnknownProviderError
      </code>
    </td>
    
    <td>
      The name isn't in the registry. <code>
        Unknown provider: nope
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        InvalidInputError
      </code>
    </td>
    
    <td>
      The arguments contradict each other, like <code>
        selector
      </code>
      
       with <code>
        fullPage: true
      </code>
      
      , or one is out of range, like <code>
        maxChars: 0
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        EmptyUrlError
      </code>
    </td>
    
    <td>
      The URL is empty or just whitespace, like a template variable nobody filled. Nothing leaves the machine and no Chromium starts. It's an <code>
        InvalidInputError
      </code>
      
       too, so that catch already covers it
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        UnsupportedOperationError
      </code>
    </td>
    
    <td>
      The provider can't do it. Anchor asked to scrape, or no configured provider can extract
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        NavigationError
      </code>
    </td>
    
    <td>
      The site didn't serve the page, and the browser gave up on it. <code>
        reason
      </code>
      
       holds Chrome's verdict, like <code>
        HTTP ERROR 500
      </code>
      
       or <code>
        ERR_NAME_NOT_RESOLVED
      </code>
      
      , or the text Kernel's proxy wrote in its place. Lightpanda isn't Chrome, so it gives its own name, like <code>
        CouldntResolveHost
      </code>
      
      . <code>
        statusCode
      </code>
      
       holds the status when one came back. Steel reads the site's off Chrome's error page, Kernel gives its proxy's, like 502 for a host that doesn't resolve. <code>
        Playwright couldn't load the page, Chrome showed ERR_NAME_NOT_RESOLVED
      </code>
      
      . Every provider gets the same 500, so no need to go shopping for another
    </td>
  </tr>
</tbody>
</table>

## Fix the setup

<table>
<thead>
  <tr>
    <th>
      Class
    </th>
    
    <th>
      When
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        AuthError
      </code>
    </td>
    
    <td>
      Key missing, or the vendor said 401. <code>
        Missing API key for steel. Set STEEL_API_KEY
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        PaymentError
      </code>
    </td>
    
    <td>
      The vendor said 402 or 403. Usually a plan or a balance
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        NoProviderConfiguredError
      </code>
    </td>
    
    <td>
      No key set for anything and nothing registered to fall back on
    </td>
  </tr>
</tbody>
</table>

## Wait, or try elsewhere

<table>
<thead>
  <tr>
    <th>
      Class
    </th>
    
    <th>
      When
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        RateLimitError
      </code>
    </td>
    
    <td>
      A 429. <code>
        retryAfter
      </code>
      
       holds the seconds, and the message names which provider refused and why
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        TimeoutError
      </code>
    </td>
    
    <td>
      No answer in time. Says how long it waited and from where
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        TransportError
      </code>
    </td>
    
    <td>
      No answer at all, because the host didn't resolve, refused the connection or failed TLS. <code>
        code
      </code>
      
       holds the system code. <code>
        No response from https://nonexistent.invalid/v1/sessions?limit=1: getaddrinfo ENOTFOUND nonexistent.invalid
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        HTTPError
      </code>
    </td>
    
    <td>
      Any other status. <code>
        statusCode
      </code>
      
      , <code>
        url
      </code>
      
       and the vendor's reason
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        SessionNotFoundError
      </code>
    </td>
    
    <td>
      The session is gone, released or expired on the vendor's side
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        BlockedPageError
      </code>
    </td>
    
    <td>
      The site gave the vendor a block page or a captcha. <code>
        Playwright returned a Reddit captcha instead of page content
      </code>
      
      . Another provider may still get through
    </td>
  </tr>
</tbody>
</table>

The package also exports `ScrapeNotSupportedError`, `SessionLimitError` and `NoProviderAvailableError`. Nothing built in throws them today, so don't write a catch for one. A provider of your own can still use them.

A rate limit and a timeout are different problems, and they come back as different classes. One says slow down, the other says nobody answered. Mixing them up is how an agent ends up hammering a vendor that already said please stop.

## Keys never leak into a message

Errors carry the request URL, so you can see which vendor failed. Query params like `token` and `api_key`, and a username or password in the URL, are replaced with `[REDACTED]` first:

```text
HTTP 400 from https://chrome.browserless.io/screenshot?token=%5BREDACTED%5D: Element not found on page! (requestId: …)
```

That line is real, from a Browserless element screenshot of a selector the page didn't have. Only the request ID is cut.


## Sitemap

See the full [sitemap](https://browsers.agntn.dev/sitemap.md) for all pages.
