Search Overlay

Error Handling

asdf

Introduction

The SDK provides a unified approach to handling errors by returning a WalletError object as a response whenever an error is returned by the Paysafe Wallet API.

Usage

JavaScript

You can use then and catch callbacks.

import { Wallet } from '@paysafe/paysafe-wallet-saas-web/wallet';

Wallet.getInstance().getProfileService().getProfile()
  .then(customerInfo => console.log('Customer info', customerInfo))
  .catch(error => console.error(error));

Try and catch blocks can also be used for in combination with async/await.

import { Wallet } from '@paysafe/paysafe-wallet-saas-web/wallet';

try {
  const customerInfo = await Wallet.getInstance().getProfileService().getProfile();
  console.log('Customer info', customerInfo);
} catch (error) {
  console.error(error);
}

Typescript

In TypeScript, you can take advantage of the CustomerInfo and WalletError interfaces.

import { Wallet } from '@paysafe/paysafe-wallet-saas-web/wallet';
import { CustomerInfo } from '@paysafe/paysafe-wallet-saas-web/profile';
import { WalletError } from '@paysafe/paysafe-wallet-saas-web/errors';

Wallet.getInstance().getProfileService().getProfile()
  .then((customerInfo: CustomerInfo) => console.log('Customer info', customerInfo))
  .catch((error: WalletError) => console.error(error));
On this Page