I am trying to create a custom error exception in Python. I want the error to be raised if the argument is not in the dictionary `_fetch_currencies()`.

Custom error:

```
class CurrencyDoesntExistError:
    def __getcurr__(self):
        try:
            return _fetch_currencies()[self]
        except KeyError:
            raise CurrencyDoesntExistError()

```

How I have written it into my function:

```
def convert(amount, from_curr, to_curr, date=str(datetime.date.today())):
    """
    Returns the value obtained by converting the amount 'amount' of the 
    currency 'from_curr' to the currency 'to_curr' on date 'date'. If date is 
    not given, it defaults the current date.
    """
    try:    
        from_value = float(get_exrates(date)[from_curr])
        to_value = float(get_exrates(date)[to_curr])

        C = amount * (to_value / from_value)
        return C
    except CurrencyDoesntExistError:
        print('Currency does not exist')

```

I am currently getting the error message:

```
TypeError: catching classes that do not inherit from BaseException is not allowed

```

If I use `except KeyError:` in my function `convert` it will run but what is the correct way to raise this custom error exception?