message property

String message

Descriptive error message that includes the request method & URL and the response status.

Implementation

String get message {
  String msg;
  var r = request;
  if (r != null && r.autoRetry.numAttempts > 1) {
    msg = '$method $uri';
    for (int i = 0; i < r.autoRetry.failures.length; i++) {
      final failure = r.autoRetry.failures[i];
      String attempt = '\n\tAttempt #${i + 1}:';
      if (failure.response != null) {
        attempt +=
            ' ${failure.response!.status} ${failure.response!.statusText}';
      }
      if (failure.error != null) {
        attempt += ' (${failure.error})';
      }
      msg += attempt;
    }
  } else {
    msg = '$method';
    if (response != null) {
      msg += ' ${response!.status} ${response!.statusText}';
    }
    msg += ' $uri';
    if (error != null) {
      msg += '\n\t$error';
    }
  }
  return msg;
}