# ...

@responses.activate
def test_sdk_list_stores_connection_error():
    responses.add(
        responses.GET,
        api_url + "/store",
        body=requests.exceptions.ConnectionError(),
    )

    sdk = EComSDK(api_url, api_key)
    try:
        sdk.list_stores()
    except ValueError as err:
        assert "Connection error" in str(err)
    else:
        assert False, "Expected ValueError"


@responses.activate
def test_sdk_list_stores_403():
    responses.add(
        responses.GET,
        api_url + "/store",
        status=403,
    )

    sdk = EComSDK(api_url, api_key)
    try:
        sdk.list_stores()
    except ValueError as err:
        assert "Authentication error" in str(err)
    else:
        assert False, "Expected ValueError"
```

This test ensures that the helpful error message from our SDK is displayed when a connection error or 403 response occurs.

Check that the new code passes the test:

```bash
hatch run test
```

## Type Safety With Enums

To make development easier and less error-prone for our SDK users, we'll define Enums to use with the `list_products` endpoint.

Add the following Enums to the `EComSDK` class:

```python filename="src/ecom_sdk/sdk.py"
import requests
from enum import Enum

HTTP_TIMEOUT_SECONDS = 10

class EComSDK:
    # ...

    class ProductSort(str, Enum):
        PRICE = "price"
        QUANTITY = "quantity"

    class ProductSortOrder(str, Enum):
        DESC = "desc"
        ASC = "asc"

    # ...
```

The `ProductSort` and `ProductSortOrder` Enums inherit from the `str` class and can be used with the `list_products()` method we'll define next – `ProductSort` specifies the sort category, and `ProductSortOrder` determines the sort order of the product list.

Now define the `list_products()` function at the bottom of the `EComSDK` class:

```python filename="src/ecom_sdk/sdk.py"