Exceptions

The exceptions module defines the custom exception hierarchy for behave-priority.

class behave_priority.exceptions.PriorityError[source]

Bases: Exception

Base exception for all behave-priority errors.

class behave_priority.exceptions.PriorityParseError[source]

Bases: PriorityError

Raised when a priority tag has invalid syntax.

For example, priority(abc) or priority(1.5) are invalid because the value inside the parentheses is not an integer.

Hierarchy

Exception
└── PriorityError
    └── PriorityParseError

PriorityError

Base exception for all behave-priority errors. Catch this when you want to handle any error from the library:

from behave_priority import PriorityError

try:
    # ... priority operations ...
except PriorityError as e:
    print(f"Priority error: {e}")

PriorityParseError

Raised when a priority tag has invalid syntax. This includes:

  • @priority(abc) — non-integer value

  • @priority(1.5) — floating-point value

  • @priority()

  • @feature-priority(abc) — same issues for feature-level tags

from behave_priority import PriorityParseError

try:
    parse_priority(["priority(abc)"])
except PriorityParseError as e:
    print(f"Invalid tag: {e}")

The error message includes the invalid tag for debugging purposes.