in lib/src/handler.dart [64:94]
FutureOr<Response> call(Request request) async {
var requestInfo = '${request.method} /${request.url}';
if (_log) printOnFailure('[$description] $requestInfo');
try {
if (_expectations.isEmpty) {
throw TestFailure(
'$description received unexpected request $requestInfo.');
}
var expectation = _expectations.removeFirst();
if ((expectation.method != null &&
expectation.method != request.method) ||
(expectation.path != '/${request.url.path}' &&
expectation.path != null)) {
var message = '$description received unexpected request $requestInfo.';
if (expectation.method != null) {
message += '\nExpected ${expectation.method} ${expectation.path}.';
}
throw TestFailure(message);
}
return await expectation.handler(request);
} on HijackException catch (_) {
rethrow;
} catch (error, stackTrace) {
_zone.handleUncaughtError(error, stackTrace);
// We can't return null here, the handler type doesn't allow it.
return Response.internalServerError(body: '$error');
}
}