# Code and Formats
source: https://developer.mastercard.com/doconomy-aland-index/documentation/code-and-formats/index.md

## Error Handling {#error-handling}

We use standard HTTP response codes for success and failure notifications, and the errors are further classified by error type as follows:

* 200 code corresponds to success.
* 40X code for the developer or user-related failures.

## Gateway Error Codes {#gateway-error-codes}

Apart from the error codes returned by the Doconomy Aland Index API, error codes can also be returned by the Mastercard gateway, which verifies your request's signature and routes to the correct location.

For information about the 4xx response codes returned by the gateway and their possible resolutions, see [Gateway Error Codes](https://developer.mastercard.com/platform/documentation/security-and-authentication/gateway-error-codes/) for more details.

## Error Structure {#error-structure}

To ensure a consistent experience across all Mastercard APIs, the following structure is followed by the Doconomy Aland Index API for each error scenario that can occur.

Single Error:

```json
{
  "Errors": {
    "Error": [
      {
        "Source": "<source>",
        "ReasonCode": "<unique code>",
        "Description": "<short description of the error>",
        "Recoverable": true/false,
        "Details": "<Optional detailed description of the issue>"
      }
    ]
  }
}
```

Multiple Errors:

```json
{
  "Errors": {
    "Error": [
      {
        "Source": "<source>",
        "ReasonCode": "<unique code>",
        "Description": "<short description of the error>",
        "Recoverable": true/false,
        "Details": "<Optional detailed description of the issue>"
      },{
        "Source": "<source>",
        "ReasonCode": "<unique code>",
        "Description": "<short description of the error>",
        "Recoverable": true/false,
        "Details": "<Optional detailed description of the issue>"
      }
    ]
  }
}
```

|      Field      |                                                                                                                                                                        Description                                                                                                                                                                         |
|-----------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| **Source**      | The application from where the error is generated. Every error message that is generated and returned by the gateway will have this field equal to Gateway. When the value of the source field is other than the`Carbon-Calculator-Proxy,`it means the error was generated elsewhere and not by the Doconomy Aland Index API.                              |
| **ReasonCode**  | A unique constant identifying the error case encountered during Doconomy Aland Index API processing. For example, `INVALID_REQUEST_PARAMETER` is used when the request is invalid due to missing or invalid parameters.                                                                                                                                    |
| **Description** | Description of the `ReasonCode` field with additional details.                                                                                                                                                                                                                                                                                             |
| **Recoverable** | Indicates whether the error will always be returned for this request, or retrying could change the outcome. For example, if the request contains an invalid request parameter, retrying will never result in success. However, if the error is related to an unexpected timeout with the service, retrying the call could result in a successful response. |
| **Details**     | If applicable, provide detailed information regarding errors to help resolve them.                                                                                                                                                                                                                                                                         |

## Doconomy Aland Index Specific {#doconomy-aland-index-specific}

Note: The following error codes are specific to the Doconomy Aland Index API. So for the errors in the below table, the `Source` will be returned as the `Carbon-Calculator-Proxy.`For errors`Source` other than this, refer to [Gateway Error Codes](https://developer.mastercard.com/platform/documentation/gateway-error-codes/).

For a complete list of the Doconomy Aland Index API specific error codes, refer to the following table.

|         HTTP Status          |        Reason Code        |                                   Description                                   | Recoverable |
|------------------------------|---------------------------|---------------------------------------------------------------------------------|-------------|
| 400 Bad Request.             | INVALID_REQUEST_PARAMETER | One of the request parameters is invalid, try again with the correct request.   | false       |
| 415 Unsupported Media Types. | UNSUPPORTED_MEDIA_TYPE    | Requested media type is not supported, try again with the supported media type. | false       |

To resolve an error, check the `Details`error object.

Sample error object when the request object contains invalid MCC with length greater than 3:

```json
{
 "Errors": {
   "Error": [
     {
       "Source": "Carbon-Calculator-Proxy",
       "ReasonCode": "INVALID_REQUEST_PARAMETER",
       "Description": "One of the request parameters is invalid, try again with correct request.",
       "Recoverable": false,
       "Details": "transactions[0].mcc must match \"^\\d{1,4}\""
     }
   ]
 }
}
```

Sample error object when the request object contains invalid currency code with length greater than 3:

```json
{
 "Errors": {
   "Error": [
     {
       "Source": "Carbon-Calculator-Proxy",
       "ReasonCode": "INVALID_REQUEST_PARAMETER",
       "Description": "One of the request parameters is invalid, try again with correct request.",
       "Recoverable": false,
       "Details": "transactions[0].amount.currencyCode must match \"^[A-Za-z]{3}$\""
     },
     {
       "Source": "Carbon-Calculator-Proxy",
       "ReasonCode": "INVALID_REQUEST_PARAMETER",
       "Description": "One of the request parameters is invalid, try again with correct request.",
       "Recoverable": false,
       "Details": "transactions[0].amount.currencyCode size must be between 3 and 3"
     }
   ]
 }
}
```

Sample error object when the request object contains unsupported currency code:

```json
{
 "Errors": {
   "Error": [
     {
       "Source": "Carbon-Calculator-Proxy",
       "ReasonCode": "INVALID_REQUEST_PARAMETER",
       "Description": "One of the request parameters is invalid, try again with correct request.",
       "Recoverable": false,
       "Details":"cardTransactions[0].amount.currency must match \"^(EUR|GBP|RUB|SEK|USD)$\""
     }
   ]
 }
}
```

