зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1711181 - Add QM_OR_ELSE_LOG macro; r=dom-storage-reviewers,jstutte
Differential Revision: https://phabricator.services.mozilla.com/D114936
This commit is contained in:
Родитель
84d8f14b41
Коммит
cb7151e618
|
@ -406,6 +406,14 @@ nsDependentCSubstring MakeSourceFileRelativePath(
|
|||
void LogError(const nsACString& aExpr, const Maybe<nsresult> aRv,
|
||||
const nsACString& aSourceFilePath, const int32_t aSourceFileLine,
|
||||
const Severity aSeverity) {
|
||||
// TODO: Add MOZ_LOG support, bug 1711661.
|
||||
|
||||
// We have to ignore failures with the Log severity. until we have support
|
||||
// for MOZ_LOG.
|
||||
if (aSeverity == Severity::Log) {
|
||||
return;
|
||||
}
|
||||
|
||||
#if defined(EARLY_BETA_OR_EARLIER) || defined(DEBUG)
|
||||
nsAutoCString extraInfosString;
|
||||
|
||||
|
@ -435,6 +443,8 @@ void LogError(const nsACString& aExpr, const Maybe<nsresult> aRv,
|
|||
return "WARNING"_ns;
|
||||
case Severity::Note:
|
||||
return "NOTE"_ns;
|
||||
case Severity::Log:
|
||||
return "LOG"_ns;
|
||||
}
|
||||
MOZ_MAKE_COMPILER_ASSUME_IS_UNREACHABLE("Bad severity value!");
|
||||
}();
|
||||
|
|
|
@ -872,6 +872,22 @@ class NotNull;
|
|||
return orElseFunc(firstRes); \
|
||||
})
|
||||
|
||||
/**
|
||||
* QM_OR_ELSE_LOG is like QM_OR_ELSE_WARN. The only difference is that
|
||||
* failures are reported using the lowest severity which is currently ignored
|
||||
* in LogError, so nothing goes to the console, browser console and telemetry.
|
||||
* Since nothing goes to the telemetry, the macro can't signal the end of the
|
||||
* underlying error stack or change the type of the error stack in the
|
||||
* telemetry. For that reason, the expression shouldn't contain nested QM_TRY
|
||||
* macro uses.
|
||||
*/
|
||||
#define QM_OR_ELSE_LOG(expr, orElseFunc) \
|
||||
(expr).orElse([&](const auto& firstRes) { \
|
||||
mozilla::dom::quota::QM_HANDLE_ERROR(#expr, firstRes, \
|
||||
mozilla::dom::quota::Severity::Log); \
|
||||
return orElseFunc(firstRes); \
|
||||
})
|
||||
|
||||
// Telemetry probes to collect number of failure during the initialization.
|
||||
#ifdef NIGHTLY_BUILD
|
||||
# define RECORD_IN_NIGHTLY(_recorder, _status) \
|
||||
|
@ -1202,6 +1218,7 @@ enum class Severity {
|
|||
Error,
|
||||
Warning,
|
||||
Note,
|
||||
Log,
|
||||
};
|
||||
|
||||
void LogError(const nsACString& aExpr, Maybe<nsresult> aRv,
|
||||
|
|
Загрузка…
Ссылка в новой задаче