> ## Documentation Index
> Fetch the complete documentation index at: https://primer.io/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# PrimerClientError

export const HeadlessVaultManagerValidationErrorDescription = () => {
  return <>
      Indicates that the provided identifier does not match any vaulted payment
      method. This can occur during payment and when deleting a vaulted payment
      method.
    </>;
};

export const PaymentCreationDisabledErrorRecoverySuggestion = () => {
  return <>
      Call <code>universalCheckout.setPaymentCreationEnabled(true)</code> to
      reenable it
    </>;
};

export const PaymentCreationDisabledErrorDescription = () => {
  return <>
      The payment could not be created because payment creation has been
      disabled.
    </>;
};

export const ValidationErrorDescription = () => {
  return <>
      Indicates one of the following:
      <li>Bank issuer is not valid.</li>
      <li>
        Payment category is not valid (for example, when using Klarna payment
        method).
      </li>
    </>;
};

export const TokenizationErrorDescription = () => {
  return <>
      <p>
        Indicates that tokenization was not possible for a card or APM payment,
        or for a vaulted token.
      </p>
      <p>
        For new tokens, this frequently occurs due to issues validating the
        provided data from which the token is created.
      </p>
      <p>
        For vaulted tokens this can occur if a payment method token cannot be
        created from the vaulted token.
      </p>
    </>;
};

export const PrimerServerErrorDescription = () => {
  return <>
      Indicate one of the following issues when using Apple Pay or PayPal:
      <li>Failed to create Apple Pay session</li>
      <li>An error occurred when vaulting PayPal</li>
    </>;
};

export const PrimerTeardownErrorDescription = () => {
  return <>
      This error indicates that the SDK instance has been torn down and cleaned
      up.

      It means that checkout UI is removed from the DOM. UniversalCheckout
      instance is also torn down, which will raise an error if any operation that
      requires the UI is attempted.
    </>;
};

export const WebNoPaymentMethodErrorRecoverySuggestion = () => {
  return <>
      <li>
        Make sure that the payment methods are properly configured on your
        Dashboard, and that at least one payment method can be displayed with
        the data provided in the client session.
      </li>
      <li>
        Make sure that
        <code>allowedPaymentMethods</code> does not disallow all your supported payment
        methods.
      </li>
    </>;
};

export const WebNoPaymentMethodErrorDescription = () => {
  return <>
      Indicates that no payment methods were found while attempting to make a
      payment. This can occur for a number of reasons:

      <li> No payment methods were found in the client session and/or the SDK is
        not initialized.</li>
      <li> <code>allowedPaymentMethods</code> filtered out all the payment methods.</li>
    </>;
};

`PrimerClientError` is the type of errors returned by the SDK. Each error is described by an error code and description it may include contextual information.

## Properties

<Expandable title="Properties" defaultOpen>
  <ResponseField name="code" type="string">
    An error code that matches one in the table below.
  </ResponseField>

  <ResponseField name="description" type="string">
    A brief description of the error.
  </ResponseField>

  <ResponseField name="data" type="object">
    A field containing contextual data related to the error.
  </ResponseField>

  <ResponseField name="diagnosticsId" type="string">
    A unique ID for the error instance, used internally by the SDK.
  </ResponseField>
</Expandable>

## Error Codes, Descriptions and Recovery Suggestions

| Error Code                              | Description                                                 | Recovery Suggestion                                     |
| --------------------------------------- | ----------------------------------------------------------- | ------------------------------------------------------- |
| `NO_PAYMENT_METHODS`                    | <WebNoPaymentMethodErrorDescription />                      | <WebNoPaymentMethodErrorRecoverySuggestion />           |
| `PRIMER_TEARDOWN`                       | <PrimerTeardownErrorDescription />                          | N/A                                                     |
| `PRIMER_SERVER_ERROR`                   | <PrimerServerErrorDescription />                            | Check the description for HTTP error information.       |
| `THREE_DS_AUTH_FAILED`                  | Happens when ThreeDS authentication failed.                 | Check the error description for details.                |
| `TOKENIZATION_ERROR`                    | <TokenizationErrorDescription />                            | Check the error message returned during tokenization.   |
| `DUPLICATE_PAYMENT_METHOD_ERROR`        | Indicates that the payment method is already vaulted.       |                                                         |
| `CARD_NUMBER_ERROR`                     | Indicates the provided card number is invalid.              | Display a validation error to the user.                 |
| `RESUME_ERROR`                          | Indicates that the merchant cancelled the payment.          | N/A - merchant initiated.                               |
| `VALIDATION_ERROR`                      | <ValidationErrorDescription />                              | Display a validation error to the user.                 |
| `PAYMENT_FAILED`                        | Payment failed after tokenization.                          | Check the error for details on what went wrong.         |
| `PAYMENT_CREATION_ABORTED`              | Payment creation was aborted prior to completion.           | N/A - merchant initiated.                               |
| `PAYMENT_CREATION_DISABLED`             | <PaymentCreationDisabledErrorDescription />                 | <PaymentCreationDisabledErrorRecoverySuggestion />      |
| `CLIENT_SESSION_UPDATE_ERROR`           | Failed to update the client session details.                |                                                         |
| `INVALID_ARGUMENT`                      | Invalid information was passed when initialising SDK.       | Check the error for which argument(s) need updating.    |
| `VAULT_FETCH`                           | Indicates a failure to fetch vaulted payment methods.       | Check network connection and client session.            |
| `VAULT_DELETE`                          | Indicates failure to delete a vaulted payment method.       | Check that the method hasn't already been deleted.      |
| `HEADLESS_VAULT_MANAGER_VALIDATION`     | <HeadlessVaultManagerValidationErrorDescription />          | Check that the method exists in the vault.              |
| `CARD_FORM_VALIDATION_UNEXPECTED_FIELD` | The field was not defined for the payment method.           | Removed the field and re-submit the payment.            |
| `MISSING_FIRST_NAME_OR_LAST_NAME`       | For Apple Pay, indicates a missing name field.              | The user must provide both names in their Apple wallet. |
| `IDEMPOTENCY_KEY_ALREADY_EXISTS`        | A payment with the provided idempotency key already exists. | Use a unique idempotency key for each payment request.  |
