Error and Debugging

Errors

All errors coming from the Shipping Elements can be accessing using an event listener on the ERROR event documented in Events. For example:

Copy
Copied
shippo.on('ERROR', (error) => {
    switch (error.code) {
      case 'UNAUTHORIZED':
          // The authentication token is malformed, expired or otherwise invalid.
          break;
      case 'LABEL_PURCHASE_ERROR':
        // An error occurred during label purchase
        break;
      case 'COUNTRY_NOT_SUPPORTED':
        // To or from address country is not supported
        break;
      case 'LOCALE_NOT_SUPPORTED':
        // Locale passed in the init function is not supported
        break;
      case 'UNKNOWN':
        // An unknown error happened
        break;
    }
});

Debugging

You can use the various event handlers to help debug the application. There is also a special onAny() method that will handle any events from Shippo Shipping Elements:

Copy
Copied
shippo.onAny((params) => {
  // Log any events thrown from Shippo Shipping Elements
  console.log(params);
});