# Error handling

On error, the Aerospike Python client raises an [`AerospikeError`](https://aerospike-python-client.readthedocs.io/en/latest/exception.html) exception or one of its subclasses. The exception includes the following attributes:

-   `code` — The error code that identifies the error. See [as\_status.h of the Aerospike C client](https://aerospike.com/apidocs/c/dc/d42/as__status_8h_source.html) for error code descriptions.
-   `msg` — The error message with details.
-   `file` — The file where the error occurred.
-   `line` — The line number in the file where the error occurred.

## Exception Handling

To handle the exceptions, wrap the code in a `try-except` block:

```python
from __future__ import print_function

import aerospike

from aerospike.exception import *

try:

  config = { 'hosts': [ ('127.0.0.1', 3000)], 'policies': { 'timeout': 1200}}

  client = aerospike.client(config)

  client.close()

except ClientError as e:

  print("Error: {0} [{1}]".format(e.msg, e.code))
```