fune/browser/app/winlauncher/ErrorHandler.h
Toshihito Kikuchi 18aab300b5 Bug 1576697 - Use LauncherResult in WinHeaderOnlyUtils.h instead of WindowsErrorResult. r=aklotz
`WindowsErrorResult` is a class to hold either a value or a Windows error
code based on the `Result` template.  We also have `LauncherResult` for the
same purpose, which was introduced as a part of the launcher process feature
afterward.  The difference is `LauncherResult` holds a filename and line
number along with an error code.

This patch integrates LauncherResult.h into WinHeaderOnlyUtils.h so that we
can use `LauncherResult` more broadly.

Differential Revision: https://phabricator.services.mozilla.com/D44512

--HG--
extra : moz-landing-system : lando
2019-09-07 18:17:45 +00:00

51 lines
1.5 KiB
C++

/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
#ifndef mozilla_ErrorHandler_h
#define mozilla_ErrorHandler_h
#include "mozilla/Assertions.h"
#include "mozilla/WinHeaderOnlyUtils.h"
namespace mozilla {
/**
* All launcher process error handling should live in the implementation of
* this function.
*/
void HandleLauncherError(const LauncherError& aError);
// This function is simply a convenience overload that automatically unwraps
// the LauncherError from the provided LauncherResult and then forwards it to
// the main implementation.
template <typename T>
inline void HandleLauncherError(const LauncherResult<T>& aResult) {
MOZ_ASSERT(aResult.isErr());
if (aResult.isOk()) {
return;
}
HandleLauncherError(aResult.inspectErr());
}
// This function is simply a convenience overload that unwraps the provided
// GenericErrorResult<LauncherError> and forwards it to the main implementation.
inline void HandleLauncherError(
const GenericErrorResult<LauncherError>& aResult) {
LauncherVoidResult r(aResult);
HandleLauncherError(r);
}
// Forward declaration
struct StaticXREAppData;
void SetLauncherErrorAppData(const StaticXREAppData& aAppData);
void SetLauncherErrorForceEventLog();
} // namespace mozilla
#endif // mozilla_ErrorHandler_h