# Handle buyer errors (/platforms/checkout/advanced/customize/handle-errors)



Handle buyer errors to provide a unique buyer experience.

## Know before you code [#know-before-you-code]

* These capabilities *modify* an existing [checkout integration](/platforms/checkout/).
* Complete the steps in [Get started](/platforms/get-started) to get the following sandbox account information from the Developer Dashboard:
  * Your sandbox account login information
  * Your access token
* These client-side and server-side integration capabilities use the following:
  * PayPal JavaScript SDK
  * [Orders REST API](/api/orders/v2/)  —                   [Create order](/api/orders/v2/orders-create/) endpoint

## Handle errors [#handle-errors]

These procedures apply to [standard](/platforms/checkout/standard/) and [advanced](/platforms/checkout/advanced/) integrations.

### Buyer checkout error [#buyer-checkout-error]

If an error prevents buyer checkout, alert the user that an error has occurred with the buttons using the `onError` callback:

<div className="pl-[1.625rem]" />

```javascript lineNumbers
paypal.Buttons({
  onError: function (err) {
    // For example, redirect to a specific error page
    window.location.href = "/your-error-page-here";
  }
}).render('#paypal-button-container');
```

This error handler is a catch-all. Errors at this point are not expected to be handled beyond showing a generic error message or page.

### Script not loading error [#script-not-loading-error]

If null pointer errors prevent the script from loading, provide a different checkout experience:

<div className="pl-[1.625rem]" />

```javascript lineNumbers
if (window.paypal && window.paypal.Buttons) {
  // render the buttons
} else {
  // show a fallback experience
}
```
