irahorecka / pycraigslist

Craigslist API wrapper
MIT License
41 stars 14 forks source link

pycraigslist.query.filters.parse_filters() should throw custom exception #8

Closed ChristopherJHart closed 3 years ago

ChristopherJHart commented 3 years ago

Right now, the pycraigslist.query.filters.parse_filters() function throws ValueError with a string indicating a filter has an incorrect value.

It would be nice if we can create a custom exception inherited from ValueError that takes in the filter name and incorrect value as parameters. This promotes more graceful error-handling in applications using pycraigslist.

I'm thinking something like this in pycraigslist.exceptions:

class InvalidFilterValue(ValueError):
    def __init__(self, name, value):
        self.name = name
        self.value = value