Skip to main content

Module error

Module error 

Source
Expand description

The error type of the operations that validate whole inputs, and the panics of the others.

The Java implementation distinguishes IndexOutOfBoundsException (an index or ID outside its range) from IllegalArgumentException (any other violated contract) and, for a builder at its limit, IllegalStateException. Rust keeps the same distinction in two forms:

  • Operations that validate whole inputs return a Result whose GraphError names the category in its ErrorKind. Whole inputs are arrays that must form a graph, a mapping or a partition, and graphs that must be acyclic or a forest.
  • Single arguments out of their range panic, like an out-of-bounds slice index. So does a mapping that breaks its contract where it is used, in NodeMapping::inverted, compose and graphs::remapped: one that maps two indices to the same index, or that maps outside the space the call names. NodeMapping::of leaves the first of these to the caller, as Java does. The panic message starts with the category: index out of bounds: , invalid argument: or illegal state: .

Structs§

GraphError
An input that does not meet the contract of the operation it was passed to: the error of the operations that check a whole input, such as Graph::of or top_order::of.

Enums§

ErrorKind
The category of a GraphError: the counterpart of the Java exception class.