abort method
Aborts request. To use this, request interception should be enabled with
page.setRequestInterception
.
Exception is immediately thrown if the request interception is not enabled.
Parameters:
error
: Optional error code. Defaults to failed
Implementation
Future<void> abort({ErrorReason? error}) async {
error ??= ErrorReason.failed;
// Request interception is not supported for data: urls.
if (url.startsWith('data:')) return;
assert(allowInterception, 'Request Interception is not enabled!');
assert(!_interceptionHandled, 'Request is already handled!');
_interceptionHandled = true;
await _fetchApi
.failRequest(fetch.RequestId(interceptionId!), error)
.catchError((error) {
// In certain cases, protocol will return error if the request was already canceled
// or the page was closed. We should tolerate these errors.
_logger.finer('[Request.abort] swallow error: $error');
});
}