# Error Codes

The cloud agent returns informative errors codes where possible, resorting to a generic message for all other cases.

## Error codes

| Code                            | Description                                                                                                                                                                                                          |
| ------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `InvalidArgumentError`          | Returned by any `query` or `mutation` when invalid arguments or invalid argument combinations are submitted.                                                                                                         |
| `DecodingError`                 | Returned when a string-encoded JSON input argument cannot be successfully decoded to valid JSON.                                                                                                                     |
| `ResourceAlreadyExistsError`    | Returned when attempting to create a resource (e.g. an `AnoncredsSchema` etc.) which already exists.                                                                                                                 |
| `LedgerWriteError`              | Returned when the cloud agent fails to write an `AnoncredsSchema` or `AnoncredsCredDef` to the ledger, and the cause of failure is unknown.                                                                          |
| `ResourceNotFoundError`         | Returned when attempting to fetch a resource (e.g. a `Connection`, `Credential`, exchange, ledger resource etc.) which does not exist.                                                                               |
| `CannotIssueWithCredDefError`   | Returned when attempting to issue an Anoncreds credential but the specified `credDefId` references a credential definition which was not created by the cloud agent.                                                 |
| `ExchangeInAbandonedStateError` | Returned when attempting to perform an operation on an exchange, but the exchange is in the state `ABANDONED` and therefore the cloud agent cannot fulfill the operation request.                                    |
| `IncompletePresentationError`   | Returned when attempting to accept a proof request by submitting a presentation, but the submitted presentation is lacking sufficient arguments such that the proof request is not fulfilled. e.g. missing referents |

## Generic errors

As a fallback, generic errors are returned from the cloud agent in the following form, where `<uuidv4>` is replaced with a random UUID v4.

```
Service error. RefId: <uuidv4>
```
