mirror of
https://github.com/samsonjs/vdirsyncer.git
synced 2026-03-25 08:55:50 +00:00
Merge pull request #466 from pimutils/collections-null-google
Improve error for unsupported collections = null
This commit is contained in:
commit
a8c79ed1fc
4 changed files with 16 additions and 1 deletions
|
|
@ -137,6 +137,11 @@ def handle_cli_error(status_name=None):
|
|||
'the issue tracker at {}'
|
||||
.format(e, BUGTRACKER_HOME)
|
||||
)
|
||||
except exceptions.CollectionRequired as e:
|
||||
cli_logger.error(
|
||||
'One or more storages don\'t support `collections = null`. '
|
||||
'You probably want to set `collections = ["from a", "from b"]`.'
|
||||
)
|
||||
except Exception as e:
|
||||
tb = sys.exc_info()[2]
|
||||
import traceback
|
||||
|
|
|
|||
|
|
@ -75,3 +75,7 @@ class InvalidResponse(Error, ValueError):
|
|||
|
||||
class UnsupportedMetadataError(Error, NotImplementedError):
|
||||
'''The storage doesn't support this type of metadata.'''
|
||||
|
||||
|
||||
class CollectionRequired(Error):
|
||||
'''`collection = null` is not allowed.'''
|
||||
|
|
|
|||
|
|
@ -124,6 +124,9 @@ class GoogleCalendarStorage(dav.CaldavStorage):
|
|||
|
||||
def __init__(self, token_file, client_id, client_secret, start_date=None,
|
||||
end_date=None, item_types=(), **kwargs):
|
||||
if not kwargs.get('collection'):
|
||||
raise exceptions.CollectionRequired()
|
||||
|
||||
super(GoogleCalendarStorage, self).__init__(
|
||||
token_file=token_file, client_id=client_id,
|
||||
client_secret=client_secret, start_date=start_date,
|
||||
|
|
@ -155,6 +158,9 @@ class GoogleContactsStorage(dav.CarddavStorage):
|
|||
storage_name = 'google_contacts'
|
||||
|
||||
def __init__(self, token_file, client_id, client_secret, **kwargs):
|
||||
if not kwargs.get('collection'):
|
||||
raise exceptions.CollectionRequired()
|
||||
|
||||
super(GoogleContactsStorage, self).__init__(
|
||||
token_file=token_file, client_id=client_id,
|
||||
client_secret=client_secret,
|
||||
|
|
|
|||
|
|
@ -263,6 +263,6 @@ class RemoteStorageCalendars(RemoteStorage):
|
|||
|
||||
def __init__(self, **kwargs):
|
||||
if not kwargs.get('collection'):
|
||||
raise ValueError('The collections parameter is required.')
|
||||
raise exceptions.CollectionRequired()
|
||||
|
||||
super(RemoteStorageCalendars, self).__init__(**kwargs)
|
||||
|
|
|
|||
Loading…
Reference in a new issue