Skip to content
Snippets Groups Projects
Commit a8c30a08 authored by Piotr Maślanka's avatar Piotr Maślanka
Browse files

changed `ImpossibleError` to be a `BaseException`

parent 4f934f39
No related branches found
No related tags found
No related merge requests found
...@@ -2,3 +2,4 @@ ...@@ -2,3 +2,4 @@
* added `sleep_interval` to `hang_until_sig` * added `sleep_interval` to `hang_until_sig`
* added `read_lines` * added `read_lines`
* changed `ImpossibleError` to be a `BaseException`
...@@ -97,6 +97,9 @@ ImpossibleError ...@@ -97,6 +97,9 @@ ImpossibleError
.. autoclass:: satella.exceptions.ImpossibleError .. autoclass:: satella.exceptions.ImpossibleError
:members: :members:
Note that `ImpossibleError` inherits from `BaseException` instead of the standard Satella hierarchy.
The thought is, since this is an anomalous exception, it should get to the top of the stack ASAP.
Satella-specific exceptions Satella-specific exceptions
=========================== ===========================
......
__version__ = '2.14.31a4' __version__ = '2.14.31a5'
...@@ -219,10 +219,10 @@ class ProcessFailed(BaseSatellaError, OSError): ...@@ -219,10 +219,10 @@ class ProcessFailed(BaseSatellaError, OSError):
return 'ProcessFailed(%s)' % (self.rc,) return 'ProcessFailed(%s)' % (self.rc,)
class ImpossibleError(BaseSatellaError, RuntimeError): class ImpossibleError(BaseException):
""" """
For these cases where your execution flow goes some place, that should be impossible For these cases where your execution flow goes some place, that should be impossible
for it to reach. for it to reach.
Also inherits from `RuntimeError` This is a BaseException, since it should be propagated upwards as soon as possible!
""" """
import unittest import unittest
from satella.exceptions import BaseSatellaError, CustomException, CodedCustomException from satella.exceptions import BaseSatellaError, CustomException, CodedCustomException, \
ImpossibleError
class TestExceptions(unittest.TestCase): class TestExceptions(unittest.TestCase):
def test_impossible_error(self):
try:
raise ImpossibleError()
except Exception:
self.fail('failed')
except BaseException:
pass
else:
self.fail('failed')
def test_exception_kwargs(self): def test_exception_kwargs(self):
e = BaseSatellaError('hello world', label='value') e = BaseSatellaError('hello world', label='value')
self.assertIn("label='value'", repr(e)) self.assertIn("label='value'", repr(e))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment