next method

  1. @override
Future<Response> next(
  1. Request request
)
override

This method is called on every request. Calling super.next will cause invocation of next method in the next ApiLink in the chain (if present)

Implementation

@override
Future<Response> next(Request request) async {
  final response = await super.next(request);

  if (response.ok) {
    return response;
  } else {
    final exception = RequestException.fromResponse(response);

    assert(() {
      print(
        '[$runtimeType DEBUG]: Exeption thrown: '
        '${exception.runtimeType}(\'${exception.message}\')',
      );
      return true;
    }());

    throw exception;
  }
}