mirror of
https://github.com/samsonjs/vdirsyncer.git
synced 2026-04-27 14:57:41 +00:00
parent
0f5bce333e
commit
b5b6788a3b
3 changed files with 7 additions and 10 deletions
|
|
@ -29,14 +29,11 @@ class CliError(RuntimeError):
|
||||||
self.problems = problems
|
self.problems = problems
|
||||||
RuntimeError.__init__(self, msg)
|
RuntimeError.__init__(self, msg)
|
||||||
|
|
||||||
def format_cli(self):
|
def __str__(self):
|
||||||
msg = self.msg.rstrip(u'.:')
|
msg = self.msg.rstrip(u'.:')
|
||||||
if self.problems:
|
li = u'\n - '
|
||||||
msg += u':'
|
for problem in self.problems or ():
|
||||||
if len(self.problems) == 1:
|
msg += u'{}{}'.format(li, problem)
|
||||||
msg += u' {}'.format(self.problems[0])
|
|
||||||
else:
|
|
||||||
msg += u'\n' + u'\n - '.join(self.problems) + u'\n\n'
|
|
||||||
|
|
||||||
return msg
|
return msg
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -48,8 +48,8 @@ def _validate_general_section(general_config):
|
||||||
.format(u', '.join(missing)))
|
.format(u', '.join(missing)))
|
||||||
|
|
||||||
if problems:
|
if problems:
|
||||||
raise CliError(u'Invalid general section. You should copy the example '
|
raise CliError(u'Invalid general section. Copy the example '
|
||||||
u'config from the repository and edit it: {}\n'
|
u'config from the repository and edit it: {}'
|
||||||
.format(PROJECT_HOME), problems=problems)
|
.format(PROJECT_HOME), problems=problems)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,7 @@ def handle_cli_error(status_name=None):
|
||||||
try:
|
try:
|
||||||
raise
|
raise
|
||||||
except CliError as e:
|
except CliError as e:
|
||||||
cli_logger.critical(e.format_cli())
|
cli_logger.critical(e)
|
||||||
except StorageEmpty as e:
|
except StorageEmpty as e:
|
||||||
cli_logger.error(
|
cli_logger.error(
|
||||||
'{status_name}: Storage "{name}" was completely emptied. If you '
|
'{status_name}: Storage "{name}" was completely emptied. If you '
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue