Rev 5457: Using dedicated exceptions feels cleaner. in file:///home/vila/src/bzr/experimental/config/
Vincent Ladeuil
v.ladeuil+lp at free.fr
Mon Oct 4 15:08:11 BST 2010
At file:///home/vila/src/bzr/experimental/config/
------------------------------------------------------------
revno: 5457
revision-id: v.ladeuil+lp at free.fr-20101004140811-jsdrmydty0qsmhoi
parent: v.ladeuil+lp at free.fr-20101004103536-tuiee9cbh2hu7ef0
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: config-modify
timestamp: Mon 2010-10-04 16:08:11 +0200
message:
Using dedicated exceptions feels cleaner.
-------------- next part --------------
=== modified file 'bzrlib/config.py'
--- a/bzrlib/config.py 2010-10-04 10:35:36 +0000
+++ b/bzrlib/config.py 2010-10-04 14:08:11 +0000
@@ -1788,7 +1788,7 @@
conf.set_user_option(name, value)
break
else:
- raise errors.BzrError('%s is not a known configuration' % (force,))
+ raise errors.NoSuchConfig(force)
def _remove_config_option(self, name, directory, force):
removed = False
@@ -1803,6 +1803,6 @@
break
break
else:
- raise errors.BzrError('%s is not a known configuration' % (force,))
+ raise errors.NoSuchConfig(force)
if not removed:
- raise errors.BzrError('%s is not a known option' % (name,))
+ raise errors.NoSuchConfigOption(name)
=== modified file 'bzrlib/errors.py'
--- a/bzrlib/errors.py 2010-09-13 06:36:59 +0000
+++ b/bzrlib/errors.py 2010-10-04 14:08:11 +0000
@@ -2945,6 +2945,22 @@
self.user_encoding = osutils.get_user_encoding()
+class NoSuchConfig(BzrError):
+
+ _fmt = ('The "%(config_id)s" configuration does not exist.')
+
+ def __init__(self, config_id):
+ BzrError.__init__(self, config_id=config_id)
+
+
+class NoSuchConfigOption(BzrError):
+
+ _fmt = ('The "%(option_name)s" configuration option does not exist.')
+
+ def __init__(self, option_name):
+ BzrError.__init__(self, option_name=option_name)
+
+
class NoSuchAlias(BzrError):
_fmt = ('The alias "%(alias_name)s" does not exist.')
=== modified file 'bzrlib/tests/blackbox/test_config.py'
--- a/bzrlib/tests/blackbox/test_config.py 2010-10-04 09:47:39 +0000
+++ b/bzrlib/tests/blackbox/test_config.py 2010-10-04 14:08:11 +0000
@@ -84,7 +84,7 @@
_t_config.create_configs(self)
def test_unknown_config(self):
- self.run_bzr_error(['moon is not a known configuration'],
+ self.run_bzr_error(['The "moon" configuration does not exist'],
['config', '--force', 'moon', 'hello=world'])
def test_bazaar_config_outside_branch(self):
@@ -135,5 +135,5 @@
_t_config.create_configs_with_file_option(self)
def test_unknown_option(self):
- self.run_bzr_error(['file is not a known option',],
+ self.run_bzr_error(['The "file" configuration option does not exist',],
['config', '--remove', 'file'])
More information about the bazaar-commits
mailing list