Proper error message on invalid configured repository type

Previoiusly, we would just bomb out with a KeyError("Foo") if a user
configured a repository Type=Foo. Or in case he tried to sync from a
Maildir to a Maildir. Still abort with an Exception now, but with one
that explains what actually had happened.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
This commit is contained in:
Sebastian Spaeth
2010-12-13 09:33:17 -06:00
committed by Nicolas Sebrecht
parent 1c106a4ce9
commit 62712cbe15
2 changed files with 73 additions and 1 deletions

View File

@ -36,7 +36,12 @@ def LoadRepository(name, account, reqtype):
raise ValueError, "Request type %s not supported" % reqtype
config = account.getconfig()
repostype = config.get('Repository ' + name, 'type').strip()
return typemap[repostype](name, account)
try:
repo = typemap[repostype]
except KeyError:
raise Exception, "'%s' repository not supported for %s repositories."%\
(repostype, reqtype)
return repo(name, account)
class BaseRepository(CustomConfig.ConfigHelperMixin):
def __init__(self, reposname, account):