errors
¶
tt error types.
errors.base
module¶
The base tt exception type.
errors.evaluation
module¶
Exception type definitions related to expression evaluation.
-
exception
tt.errors.evaluation.
DuplicateSymbolError
(message, *args)[source]¶ Bases:
tt.errors.evaluation.EvaluationError
An exception type for user-specified duplicate symbols.
>>> from tt import TruthTable >>> try: ... t = TruthTable('A or B', ordering=['A', 'A', 'B']) ... except Exception as e: ... print(type(e)) ... <class 'tt.errors.evaluation.DuplicateSymbolError'>
-
exception
tt.errors.evaluation.
EvaluationError
(message, *args)[source]¶ Bases:
tt.errors.base.TtError
An exception type for errors occurring in expression evaluation.
Note
This exception type should be sub-classed and is not meant to be raised explicitly.
-
exception
tt.errors.evaluation.
ExtraSymbolError
(message, *args)[source]¶ Bases:
tt.errors.evaluation.EvaluationError
An exception for a passed token that is not a parsed symbol.
>>> from tt import TruthTable >>> try: ... t = TruthTable('A or B', ordering=['A', 'B', 'C']) ... except Exception as e: ... print(type(e)) ... <class 'tt.errors.evaluation.ExtraSymbolError'>
-
exception
tt.errors.evaluation.
InvalidBooleanValueError
(message, *args)[source]¶ Bases:
tt.errors.evaluation.EvaluationError
An exception for an invalid truth value passed in evaluation.
>>> from tt import BooleanExpression >>> try: ... b = BooleanExpression('A or B') ... b.evaluate(A=1, B='brian') ... except Exception as e: ... print(type(e)) ... <class 'tt.errors.evaluation.InvalidBooleanValueError'>
-
exception
tt.errors.evaluation.
MissingSymbolError
(message, *args)[source]¶ Bases:
tt.errors.evaluation.EvaluationError
An exception type for a missing token value in evaluation.
>>> from tt import BooleanExpression >>> try: ... b = BooleanExpression('A and B') ... b.evaluate(A=1) ... except Exception as e: ... print(type(e)) ... <class 'tt.errors.evaluation.MissingSymbolError'>
-
exception
tt.errors.evaluation.
NoEvaluationVariationError
(message, *args)[source]¶ Bases:
tt.errors.evaluation.EvaluationError
An exception type for when evaluation of an expression will not vary.
>>> from tt import TruthTable >>> try: ... t = TruthTable('1 or 0') ... except Exception as e: ... print(type(e)) ... <class 'tt.errors.evaluation.NoEvaluationVariationError'>
errors.generic
module¶
Generic exception types.
-
exception
tt.errors.generic.
InvalidArgumentTypeError
(message, *args)[source]¶ Bases:
tt.errors.base.TtError
An exception type for invalid argument types.
>>> from tt import TruthTable >>> try: ... t = TruthTable(7) ... except Exception as e: ... print(type(e)) ... <class 'tt.errors.generic.InvalidArgumentTypeError'>
errors.grammar
module¶
Exception type definitions related to expression grammar and parsing.
-
exception
tt.errors.grammar.
BadParenPositionError
(message, expr_str=None, error_pos=None, *args)[source]¶ Bases:
tt.errors.grammar.GrammarError
An exception type for unexpected parentheses.
>>> from tt import BooleanExpression >>> try: ... b = BooleanExpression(') A or B') ... except Exception as e: ... print(type(e)) ... <class 'tt.errors.grammar.BadParenPositionError'>
-
exception
tt.errors.grammar.
EmptyExpressionError
(message, expr_str=None, error_pos=None, *args)[source]¶ Bases:
tt.errors.grammar.GrammarError
An exception type for when an empty expression is received.
>>> from tt import BooleanExpression >>> try: ... b = BooleanExpression('') ... except Exception as e: ... print(type(e)) ... <class 'tt.errors.grammar.EmptyExpressionError'>
-
exception
tt.errors.grammar.
ExpressionOrderError
(message, expr_str=None, error_pos=None, *args)[source]¶ Bases:
tt.errors.grammar.GrammarError
An exception type for unexpected operands or operators.
>>> from tt import BooleanExpression >>> try: ... b = BooleanExpression('A or or B') ... except Exception as e: ... print(type(e)) ... <class 'tt.errors.grammar.ExpressionOrderError'>
-
exception
tt.errors.grammar.
GrammarError
(message, expr_str=None, error_pos=None, *args)[source]¶ Bases:
tt.errors.base.TtError
Base type for errors that occur in the handling of expression.
Note
This exception type should be sub-classed and is not meant to be raised explicitly.
-
exception
tt.errors.grammar.
UnbalancedParenError
(message, expr_str=None, error_pos=None, *args)[source]¶ Bases:
tt.errors.grammar.GrammarError
An exception type for unbalanced parentheses.
>>> from tt import BooleanExpression >>> try: ... b = BooleanExpression('A or ((B)') ... except Exception as e: ... print(type(e)) ... <class 'tt.errors.grammar.UnbalancedParenError'>