Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2011)

Unified Diff: Source/modules/serviceworkers/FetchManager.cpp

Issue 728713003: [ServiceWorker] Provide more descriptive error messages when fetch API fails. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: use t.unreached_func instead of unreached_rejection Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « LayoutTests/http/tests/serviceworker/chromium/resources/fetch-error-messages-worker.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/serviceworkers/FetchManager.cpp
diff --git a/Source/modules/serviceworkers/FetchManager.cpp b/Source/modules/serviceworkers/FetchManager.cpp
index 60d36c97f7501562cdd2aad5c4d613fce7b9263d..97919546f3cb98c9b4d5f9949d545d98de5823ae 100644
--- a/Source/modules/serviceworkers/FetchManager.cpp
+++ b/Source/modules/serviceworkers/FetchManager.cpp
@@ -40,9 +40,9 @@ public:
private:
void performBasicFetch();
- void performNetworkError();
+ void performNetworkError(const String& message);
void performHTTPFetch();
- void failed();
+ void failed(const String& message);
void notifyFinished();
ExecutionContext* m_executionContext;
@@ -120,17 +120,17 @@ void FetchManager::Loader::didFinishLoading(unsigned long, double)
void FetchManager::Loader::didFail(const ResourceError& error)
{
- failed();
+ failed("Fetch API cannot load " + error.failingURL() + ". " + error.localizedDescription());
}
void FetchManager::Loader::didFailAccessControlCheck(const ResourceError& error)
{
- failed();
+ failed("Fetch API cannot load " + error.failingURL() + ". " + error.localizedDescription());
}
void FetchManager::Loader::didFailRedirectCheck()
{
- failed();
+ failed("Fetch API cannot load " + m_request->url().string() + ". Redirects are not yet supported.");
}
void FetchManager::Loader::didDownloadData(int dataLength)
@@ -179,7 +179,7 @@ void FetchManager::Loader::start()
// "- |request|'s mode is |same-origin|"
if (m_request->mode() == WebURLRequest::FetchRequestModeSameOrigin) {
// "A network error."
- performNetworkError();
+ performNetworkError("Fetch API cannot load " + m_request->url().string() + ". Request mode is \"same-origin\" but the URL\'s origin is not same as the request origin " + m_request->origin()->toString() + ".");
return;
}
@@ -195,7 +195,7 @@ void FetchManager::Loader::start()
// "- |request|'s url's scheme is not one of 'http' and 'https'"
if (!m_request->url().protocolIsInHTTPFamily()) {
// "A network error."
- performNetworkError();
+ performNetworkError("Fetch API cannot load " + m_request->url().string() + ". URL scheme must be \"http\" or \"https\" for CORS request.");
return;
}
@@ -249,13 +249,13 @@ void FetchManager::Loader::performBasicFetch()
performHTTPFetch();
} else {
// FIXME: implement other protocols.
- performNetworkError();
+ performNetworkError("Fetch API cannot load " + m_request->url().string() + ". URL scheme \"" + m_request->url().protocol() + "\" is not supported.");
}
}
-void FetchManager::Loader::performNetworkError()
+void FetchManager::Loader::performNetworkError(const String& message)
{
- failed();
+ failed(message);
}
void FetchManager::Loader::performHTTPFetch()
@@ -322,7 +322,7 @@ void FetchManager::Loader::performHTTPFetch()
m_loader = ThreadableLoader::create(*m_executionContext, this, request, threadableLoaderOptions, resourceLoaderOptions);
}
-void FetchManager::Loader::failed()
+void FetchManager::Loader::failed(const String& message)
{
if (m_failed)
return;
@@ -331,7 +331,7 @@ void FetchManager::Loader::failed()
m_failed = true;
ScriptState* state = m_resolver->scriptState();
ScriptState::Scope scope(state);
- m_resolver->reject(V8ThrowException::createTypeError(state->isolate(), "Failed to fetch"));
+ m_resolver->reject(V8ThrowException::createTypeError(state->isolate(), message));
notifyFinished();
}
« no previous file with comments | « LayoutTests/http/tests/serviceworker/chromium/resources/fetch-error-messages-worker.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698