mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Merge pull request #9600 from msabramo/make_AnsibleError_a_plain_ol_exception
Make AnsibleError a plain ol' exception
This commit is contained in:
commit
ffb281d96c
2 changed files with 8 additions and 13 deletions
|
@ -17,12 +17,7 @@
|
||||||
|
|
||||||
class AnsibleError(Exception):
|
class AnsibleError(Exception):
|
||||||
''' The base Ansible exception from which all others should subclass '''
|
''' The base Ansible exception from which all others should subclass '''
|
||||||
|
pass
|
||||||
def __init__(self, msg):
|
|
||||||
self.msg = msg
|
|
||||||
|
|
||||||
def __str__(self):
|
|
||||||
return self.msg
|
|
||||||
|
|
||||||
class AnsibleFileNotFound(AnsibleError):
|
class AnsibleFileNotFound(AnsibleError):
|
||||||
pass
|
pass
|
||||||
|
|
|
@ -293,7 +293,7 @@ class TestUtils(unittest.TestCase):
|
||||||
try:
|
try:
|
||||||
ansible.utils.process_yaml_error(exc, data, __file__)
|
ansible.utils.process_yaml_error(exc, data, __file__)
|
||||||
except ansible.errors.AnsibleYAMLValidationFailed, e:
|
except ansible.errors.AnsibleYAMLValidationFailed, e:
|
||||||
self.assertTrue('Syntax Error while loading' in e.msg)
|
self.assertTrue('Syntax Error while loading' in str(e))
|
||||||
else:
|
else:
|
||||||
raise AssertionError('Incorrect exception, expected AnsibleYAMLValidationFailed')
|
raise AssertionError('Incorrect exception, expected AnsibleYAMLValidationFailed')
|
||||||
|
|
||||||
|
@ -304,7 +304,7 @@ class TestUtils(unittest.TestCase):
|
||||||
try:
|
try:
|
||||||
ansible.utils.process_yaml_error(exc, data, __file__)
|
ansible.utils.process_yaml_error(exc, data, __file__)
|
||||||
except ansible.errors.AnsibleYAMLValidationFailed, e:
|
except ansible.errors.AnsibleYAMLValidationFailed, e:
|
||||||
self.assertTrue('Syntax Error while loading' in e.msg)
|
self.assertTrue('Syntax Error while loading' in str(e))
|
||||||
else:
|
else:
|
||||||
raise AssertionError('Incorrect exception, expected AnsibleYAMLValidationFailed')
|
raise AssertionError('Incorrect exception, expected AnsibleYAMLValidationFailed')
|
||||||
|
|
||||||
|
@ -315,7 +315,7 @@ class TestUtils(unittest.TestCase):
|
||||||
try:
|
try:
|
||||||
ansible.utils.process_yaml_error(exc, data, __file__)
|
ansible.utils.process_yaml_error(exc, data, __file__)
|
||||||
except ansible.errors.AnsibleYAMLValidationFailed, e:
|
except ansible.errors.AnsibleYAMLValidationFailed, e:
|
||||||
self.assertTrue('Check over' in e.msg)
|
self.assertTrue('Check over' in str(e))
|
||||||
else:
|
else:
|
||||||
raise AssertionError('Incorrect exception, expected AnsibleYAMLValidationFailed')
|
raise AssertionError('Incorrect exception, expected AnsibleYAMLValidationFailed')
|
||||||
|
|
||||||
|
@ -326,7 +326,7 @@ class TestUtils(unittest.TestCase):
|
||||||
try:
|
try:
|
||||||
ansible.utils.process_yaml_error(exc, data, None)
|
ansible.utils.process_yaml_error(exc, data, None)
|
||||||
except ansible.errors.AnsibleYAMLValidationFailed, e:
|
except ansible.errors.AnsibleYAMLValidationFailed, e:
|
||||||
self.assertTrue('Could not parse YAML.' in e.msg)
|
self.assertTrue('Could not parse YAML.' in str(e))
|
||||||
else:
|
else:
|
||||||
raise AssertionError('Incorrect exception, expected AnsibleYAMLValidationFailed')
|
raise AssertionError('Incorrect exception, expected AnsibleYAMLValidationFailed')
|
||||||
|
|
||||||
|
@ -352,7 +352,7 @@ class TestUtils(unittest.TestCase):
|
||||||
try:
|
try:
|
||||||
ansible.utils.parse_yaml_from_file(broken)
|
ansible.utils.parse_yaml_from_file(broken)
|
||||||
except ansible.errors.AnsibleYAMLValidationFailed, e:
|
except ansible.errors.AnsibleYAMLValidationFailed, e:
|
||||||
self.assertTrue('Syntax Error while loading' in e.msg)
|
self.assertTrue('Syntax Error while loading' in str(e))
|
||||||
else:
|
else:
|
||||||
raise AssertionError('Incorrect exception, expected AnsibleYAMLValidationFailed')
|
raise AssertionError('Incorrect exception, expected AnsibleYAMLValidationFailed')
|
||||||
|
|
||||||
|
@ -594,8 +594,8 @@ class TestUtils(unittest.TestCase):
|
||||||
try:
|
try:
|
||||||
ansible.utils.deprecated('Ack!', '0.0', True)
|
ansible.utils.deprecated('Ack!', '0.0', True)
|
||||||
except ansible.errors.AnsibleError, e:
|
except ansible.errors.AnsibleError, e:
|
||||||
self.assertTrue('0.0' not in e.msg)
|
self.assertTrue('0.0' not in str(e))
|
||||||
self.assertTrue('[DEPRECATED]' in e.msg)
|
self.assertTrue('[DEPRECATED]' in str(e))
|
||||||
else:
|
else:
|
||||||
raise AssertionError("Incorrect exception, expected AnsibleError")
|
raise AssertionError("Incorrect exception, expected AnsibleError")
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue