ComparatorException constructor

ComparatorException(
  1. String message
)

Exception thrown when a comparator is used with a type that is not comparable.

Example usage:

try {
  final list = [1, 'a', 2];
  list.sort(Comparator.naturalOrder());
} catch (e) {
  if (e is ComparatorException) {
    print(e.message); // "Cannot compare 1 and a. a is not comparable."
  }
}

Implementation

ComparatorException(super.message);