diff --git a/vdirsyncer/exceptions.py b/vdirsyncer/exceptions.py index a77e77d..b9f8cdf 100644 --- a/vdirsyncer/exceptions.py +++ b/vdirsyncer/exceptions.py @@ -23,6 +23,10 @@ class Error(Exception): super(Error, self).__init__(*args) +class CollectionNotFound(Error): + '''Collection not found''' + + class PreconditionFailed(Error): ''' - The item doesn't exist although it should diff --git a/vdirsyncer/utils/__init__.py b/vdirsyncer/utils/__init__.py index f917717..90f5f8d 100644 --- a/vdirsyncer/utils/__init__.py +++ b/vdirsyncer/utils/__init__.py @@ -325,10 +325,8 @@ def checkdir(path, create=False, mode=0o750): if create: os.makedirs(path, mode) else: - raise IOError('Directory {} does not exist. Use create = ' - 'True in your configuration to automatically ' - 'create it, or create it ' - 'yourself.'.format(path)) + raise exceptions.CollectionNotFound('Directory {} does not exist.' + .format(path)) def checkfile(path, create=False): @@ -343,10 +341,8 @@ def checkfile(path, create=False): if os.path.exists(path): raise IOError('{} is not a file.'.format(path)) if not create: - raise IOError('File {} does not exist. Use create = ' - 'True in your configuration to automatically ' - 'create it, or create it ' - 'yourself.'.format(path)) + raise exceptions.CollectionNotFound('File {} does not exist.' + .format(path)) class cached_property(object):