getErrorMessage method

String getErrorMessage({
  1. required String exceptionType,
  2. required int? min,
  3. required int? max,
})

Constructs the error message for this exception.

Implementation

String getErrorMessage({
  required String exceptionType,
  required int? min,
  required int? max,
}) {
  final StringBuffer buffer = StringBuffer(exceptionType);

  if (message != null) {
    buffer.write(": $message");
  }

  if (value != null) {
    buffer.write("\n"
        "\tExpected: number between $min to $max (inclusive)\n"
        "\tActual: $value");
  }

  return buffer.toString();
}