# Error types, codes, and objects

## Change event error object

When DigitalRiver.js detects a problem with an [element](/digital-river-api/developer-resources/reference/elements.md), its [change event](/digital-river-api/developer-resources/reference/elements.md#change) returns an `error` that contains a `type`, `code`, and `message`.

{% tabs %}
{% tab title="Change Event Error object" %}

```javascript
{
    "type": "validation_error",
    "code": "invalid_card_number",
    "message": "Your card number is invalid."
}
```

{% endtab %}
{% endtabs %}

## Create source error object

If a problem occurs during the tokenization request, the [`createSource`](/digital-river-api/developer-resources/reference/digitalriver-object.md#creating-sources) method and [`on source`](/digital-river-api/developer-resources/reference/elements.md#source) event return an error with a `type` and an array of `errors[]`, each of which contains a detailed `message`.

{% tabs %}
{% tab title="Create Source Error object" %}

```javascript
{
    "type": "bad_request",
    "errors": [{
           "code": "invalid_parameter",
           "parameter": "owner.firstName",
           "message": "'' is not a valid owner.firstname."
    },
    {
            "code": "currency_unsupported",
            "parameter": "currency",
            "message": "currency 'xyz' is not supported."
    }]
}
```

{% endtab %}
{% endtabs %}

## Error codes

The following table contains a list of DigitalRiver.js error codes.

{% hint style="info" %}
You must only indicate that the payment has been declined, and you must not share the code or descriptions below with the customer.
{% endhint %}

| Code                      | Description                                                                                                                                                                 |
| ------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `address_mismatch`        | There is a problem with your address.                                                                                                                                       |
| `invalid_expiration_date` | The card is expired or the expiration date is invalid.                                                                                                                      |
| `invalid_format`          | The format of your request is invalid.                                                                                                                                      |
| `invalid_parameter`       | The parameter is invalid. Check the [Digital River API Reference](https://docs.digitalriver.com/digital-river-api-reference/) to see which values are valid and try again.  |
| `invalid_string_empty`    | The string value is empty. Provide a valid string value and try again.                                                                                                      |
| `method_not_allowed`      | The method is not allowed. Provide a valid method value and try again.                                                                                                      |
| `missing_parameter`       | A parameter is missing. Chec[k the Digital River API Reference](https://docs.digitalriver.com/digital-river-api-reference/) to see which values are required and try again. |
| `not_found`               | The item requested was not found.                                                                                                                                           |
| `source_not_found`        | The source you have requested was not found.                                                                                                                                |
| `unknown_error`           | An unknown error has occurred                                                                                                                                               |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.digitalriver.com/digital-river-api/developer-resources/reference/error-types-codes-and-objects.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
