# Connector/Python Exception Handling - Example
```
import mysql.connector
from mysql.connector.errorcode import (
    ER_ACCESS_DENIED_ERROR,
    ER_BAD_DB_ERROR,
)

try:
    connection = mysql.connector.connect(
        user="u1", password="secret", database="errordb"
    )
~!@except mysql.connector.Error as ex@!~:
    if ex.errno == ER_ACCESS_DENIED_ERROR:
        print("Credentials error")
    elif ex.errno == ER_BAD_DB_ERROR:
        print("Database does not exist")
    else:
        print(f"There is an error: {ex}")
else:
    connection.close()
```
-----------------------------------------------------
[no notes]