PyRatException

class PyRatException[source]

Bases: Exception

(This class inherits from Exception ).

The exception raised by PyRat when the library is used incorrectly, or cannot do what it is asked. Typical causes are an invalid argument given to a class or a function of the library (e.g., a vertex that is not in a graph, or a percentage greater than 100), a workspace that cannot be created, or a game interrupted by the user (Ctrl+C in the terminal).

Errors caused by players during a game are reported with PyRatPlayerException, which inherits from this class.

Here is an example of how to catch it:

from pyrat import Graph, PyRatException

graph = Graph()
graph.add_vertex(0)
try:
    graph.get_neighbors(1)
except PyRatException as error:
    print("Invalid use of the library:", error)