Skip to content

Commit

Permalink
Add the BytesSyntaxError class
Browse files Browse the repository at this point in the history
  • Loading branch information
zeroSteiner committed Jun 8, 2024
1 parent b20667a commit 548a6bd
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
6 changes: 6 additions & 0 deletions docs/source/rule_engine/errors.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ Exceptions
:show-inheritance:
:special-members: __init__

.. autoexception:: BytesSyntaxError
:members:
:show-inheritance:
:special-members: __init__

.. autoexception:: DatetimeSyntaxError
:members:
:show-inheritance:
Expand Down Expand Up @@ -100,6 +105,7 @@ The class hierarchy for Rule Engine exceptions is:
+-- SymbolResolutionError
+-- SymbolTypeError
+-- SyntaxError
+-- BytesSyntaxError
+-- DatetimeSyntaxError
+-- FloatSyntaxError
+-- RegexSyntaxError
Expand Down
15 changes: 15 additions & 0 deletions lib/rule_engine/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,21 @@ class EvaluationError(EngineError):
class SyntaxError(EngineError):
"""A base error for syntax related issues."""

class BytesSyntaxError(SyntaxError):
"""
An error raised for issues regarding the use of improperly formatted bytes expressions.
.. versionadded:: 4.5.0
"""
def __init__(self, message, value):
"""
:param str message: A text description of what error occurred.
:param str value: The bytes value which contains the syntax error which caused this exception to be raised.
"""
super(BytesSyntaxError, self).__init__(message)
self.value = value
"""The bytes value which contains the syntax error which caused this exception to be raised."""

class DatetimeSyntaxError(SyntaxError):
"""An error raised for issues regarding the use of improperly formatted datetime expressions."""
def __init__(self, message, value):
Expand Down

0 comments on commit 548a6bd

Please sign in to comment.