Add base exception class for this library
To make it easier for users of this library to differentiate general exceptions from automaton exceptions it is quite common to have a root exception class that libraries use (and derive there exceptions from); this adds that. Change-Id: I140cb188f58849ac5caea97ed5a422375b549f6f
This commit is contained in:
parent
59d34fa3ed
commit
fd1d81a90c
@ -15,23 +15,27 @@
|
||||
# under the License.
|
||||
|
||||
|
||||
class InvalidState(Exception):
|
||||
class AutomatonException(Exception):
|
||||
"""Base class for *most* exceptions emitted from this library."""
|
||||
|
||||
|
||||
class InvalidState(AutomatonException):
|
||||
"""Raised when a invalid state transition is attempted while executing."""
|
||||
|
||||
|
||||
class NotInitialized(Exception):
|
||||
class NotInitialized(AutomatonException):
|
||||
"""Error raised when an action is attempted on a not inited machine."""
|
||||
|
||||
|
||||
class NotFound(Exception):
|
||||
class NotFound(AutomatonException):
|
||||
"""Raised when some entry in some object doesn't exist."""
|
||||
|
||||
|
||||
class Duplicate(Exception):
|
||||
class Duplicate(AutomatonException):
|
||||
"""Raised when a duplicate entry is found."""
|
||||
|
||||
|
||||
class FrozenMachine(Exception):
|
||||
class FrozenMachine(AutomatonException):
|
||||
"""Exception raised when a frozen machine is modified."""
|
||||
|
||||
def __init__(self):
|
||||
|
@ -28,3 +28,10 @@ Exceptions
|
||||
|
||||
.. automodule:: automaton.exceptions
|
||||
:members:
|
||||
|
||||
Hierarchy
|
||||
---------
|
||||
|
||||
.. inheritance-diagram::
|
||||
automaton.exceptions
|
||||
:parts: 1
|
||||
|
@ -23,7 +23,8 @@ sys.path.insert(0, os.path.abspath('../..'))
|
||||
extensions = [
|
||||
'sphinx.ext.autodoc',
|
||||
'sphinx.ext.doctest',
|
||||
'oslosphinx'
|
||||
'sphinx.ext.inheritance_diagram',
|
||||
'oslosphinx',
|
||||
]
|
||||
|
||||
# autodoc generation is a bit aggressive and a nuisance when doing heavy
|
||||
|
Loading…
x
Reference in New Issue
Block a user