mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
feat(Request): introduce Request.failure() method (#1065)
Similarly to the `request.response()` method, this patch adds `request.failure()` method that returns error details for the failed requests. Fixes #901.
This commit is contained in:
@@ -259,6 +259,7 @@ class NetworkManager extends EventEmitter {
|
||||
// @see https://crbug.com/750469
|
||||
if (!request)
|
||||
return;
|
||||
request._failureText = event.errorText;
|
||||
request._completePromiseFulfill.call(null);
|
||||
this._requestIdToRequest.delete(request._requestId);
|
||||
this._interceptionIdToRequest.delete(request._interceptionId);
|
||||
@@ -284,6 +285,7 @@ class Request {
|
||||
this._allowInterception = allowInterception;
|
||||
this._interceptionHandled = false;
|
||||
this._response = null;
|
||||
this._failureText = null;
|
||||
this._completePromise = new Promise(fulfill => {
|
||||
this._completePromiseFulfill = fulfill;
|
||||
});
|
||||
@@ -304,6 +306,17 @@ class Request {
|
||||
return this._response;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {?{errorText: string}}
|
||||
*/
|
||||
failure() {
|
||||
if (!this._failureText)
|
||||
return null;
|
||||
return {
|
||||
errorText: this._failureText
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {!Object=} overrides
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user