Bug 1439455 - Display error names instead of codes in about:url-classifier. r=gcp

This also changes a few MOZ_LOG() messages to use the error name
instead of the raw numerical nsresult value.

MozReview-Commit-ID: Jcngd0S9j2z

--HG--
extra : rebase_source : f6e974569d8845211e0b25dabef2c41dda2ca1b6
This commit is contained in:
Francois Marier 2018-02-22 17:37:53 -08:00
parent ef563d5e49
commit b401105973
4 changed files with 23 additions and 12 deletions

View File

@ -864,6 +864,8 @@ ProtocolParserProtobuf::ProcessOneResponse(const ListUpdateResponse& aResponse)
PARSER_LOG(("* newState: %s\n", aResponse.new_client_state().c_str()));
PARSER_LOG(("* isFullUpdate: %s\n", (isFullUpdate ? "yes" : "no")));
PARSER_LOG(("* hasChecksum: %s\n", (aResponse.has_checksum() ? "yes" : "no")));
PARSER_LOG(("* additions: %d\n", aResponse.additions().size()));
PARSER_LOG(("* removals: %d\n", aResponse.removals().size()));
tuV4->SetFullUpdate(isFullUpdate);

View File

@ -573,13 +573,11 @@ nsUrlClassifierDBServiceWorker::FinishStream()
if (mProtocolParser->ResetRequested()) {
mClassifier->ResetTables(Classifier::Clear_All, mUpdateTables);
}
} else {
mUpdateStatus = NS_ERROR_UC_UPDATE_PROTOCOL_PARSER_ERROR;
}
mProtocolParser = nullptr;
return NS_OK;
return mUpdateStatus;
}
NS_IMETHODIMP

View File

@ -53,6 +53,7 @@ const uint32_t FETCH_NEXT_REQUEST_RETRY_DELAY_MS = 1000;
// MOZ_LOG=UrlClassifierStreamUpdater:5
static mozilla::LazyLogModule gUrlClassifierStreamUpdaterLog("UrlClassifierStreamUpdater");
#define LOG(args) TrimAndLog args
#define LOG_ENABLED() MOZ_LOG_TEST(gUrlClassifierStreamUpdaterLog, mozilla::LogLevel::Debug)
// Calls nsIURLFormatter::TrimSensitiveURLs to remove sensitive
// info from the logging message.
@ -408,7 +409,10 @@ nsUrlClassifierStreamUpdater::FetchNext()
true, // This method is for v2 and v2 is always a POST.
update.mTable);
if (NS_FAILED(rv)) {
LOG(("Error fetching update url: %s\n", update.mUrl.get()));
nsAutoCString errorName;
mozilla::GetErrorName(rv, errorName);
LOG(("Error (%s) fetching update url: %s\n", errorName.get(),
update.mUrl.get()));
// We can commit the urls that we've applied so far. This is
// probably a transient server problem, so trigger backoff.
mDownloadError = true;
@ -475,8 +479,12 @@ nsUrlClassifierStreamUpdater::StreamFinished(nsresult status,
// We are a service and may not be reset with Init between calls, so reset
// mBeganStream manually.
mBeganStream = false;
LOG(("nsUrlClassifierStreamUpdater::StreamFinished [%" PRIx32 ", %d]",
static_cast<uint32_t>(status), requestedDelay));
if (LOG_ENABLED()) {
nsAutoCString errorName;
mozilla::GetErrorName(status, errorName);
LOG(("nsUrlClassifierStreamUpdater::StreamFinished [%s, %d]",
errorName.get(), requestedDelay));
}
if (NS_FAILED(status) || mPendingUpdates.Length() == 0) {
// We're done.
LOG(("nsUrlClassifierStreamUpdater::Done [this=%p]", this));
@ -546,9 +554,9 @@ nsUrlClassifierStreamUpdater::UpdateError(nsresult result)
mDownloadError ? mCurrentRequest->mDownloadErrorCallback.get() : nullptr;
DownloadDone();
nsAutoCString strResult;
strResult.AppendInt(static_cast<uint32_t>(result));
if (errorCallback) {
nsAutoCString strResult;
mozilla::GetErrorName(result, strResult);
errorCallback->HandleEvent(strResult);
} else if (downloadErrorCallback) {
LOG(("Notify download error callback in UpdateError [this=%p]", this));
@ -606,7 +614,7 @@ nsUrlClassifierStreamUpdater::OnStartRequest(nsIRequest *request,
rv = httpChannel->GetStatus(&status);
NS_ENSURE_SUCCESS(rv, rv);
if (MOZ_LOG_TEST(gUrlClassifierStreamUpdaterLog, mozilla::LogLevel::Debug)) {
if (LOG_ENABLED()) {
nsAutoCString errorName, spec;
mozilla::GetErrorName(status, errorName);
nsCOMPtr<nsIURI> uri;
@ -720,8 +728,12 @@ nsUrlClassifierStreamUpdater::OnStopRequest(nsIRequest *request, nsISupports* co
if (!mDBService)
return NS_ERROR_NOT_INITIALIZED;
LOG(("OnStopRequest (status %" PRIx32 ", beganStream %s, this=%p)",
static_cast<uint32_t>(aStatus), mBeganStream ? "true" : "false", this));
if (LOG_ENABLED()) {
nsAutoCString errorName;
mozilla::GetErrorName(aStatus, errorName);
LOG(("OnStopRequest (status %s, beganStream %s, this=%p)",
errorName.get(), mBeganStream ? "true" : "false", this));
}
nsresult rv;

View File

@ -1104,7 +1104,6 @@ with modules["URL_CLASSIFIER"]:
errors["NS_ERROR_UC_UPDATE_TABLE_NOT_FOUND"] = FAILURE(8)
errors["NS_ERROR_UC_UPDATE_BUILD_PREFIX_FAILURE"] = FAILURE(9)
errors["NS_ERROR_UC_UPDATE_FAIL_TO_WRITE_DISK"] = FAILURE(10)
errors["NS_ERROR_UC_UPDATE_PROTOCOL_PARSER_ERROR"] = FAILURE(11)
# Specific errors while parsing pver2/pver4 responses
errors["NS_ERROR_UC_PARSER_MISSING_PARAM"] = FAILURE(12)