tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

ErrorHandler.h (1601B)


      1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
      2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
      3 /* This Source Code Form is subject to the terms of the Mozilla Public
      4 * License, v. 2.0. If a copy of the MPL was not distributed with this
      5 * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
      6 
      7 #ifndef mozilla_ErrorHandler_h
      8 #define mozilla_ErrorHandler_h
      9 
     10 #include "mozilla/Assertions.h"
     11 #include "mozilla/WinHeaderOnlyUtils.h"
     12 
     13 namespace mozilla {
     14 
     15 /**
     16 * All launcher process error handling should live in the implementation of
     17 * this function.
     18 */
     19 void HandleLauncherError(const LauncherError& aError,
     20                         const char* aProcessType = nullptr);
     21 
     22 // This function is simply a convenience overload that automatically unwraps
     23 // the LauncherError from the provided LauncherResult and then forwards it to
     24 // the main implementation.
     25 template <typename T>
     26 inline void HandleLauncherError(const LauncherResult<T>& aResult,
     27                                const char* aProcessType = nullptr) {
     28  MOZ_ASSERT(aResult.isErr());
     29  if (aResult.isOk()) {
     30    return;
     31  }
     32 
     33  HandleLauncherError(aResult.inspectErr(), aProcessType);
     34 }
     35 
     36 // This function is simply a convenience overload that unwraps the provided
     37 // GenericErrorResult<LauncherError> and forwards it to the main implementation.
     38 inline void HandleLauncherError(
     39    const GenericErrorResult<LauncherError>& aResult,
     40    const char* aProcessType = nullptr) {
     41  LauncherVoidResult r(aResult);
     42  HandleLauncherError(r, aProcessType);
     43 }
     44 
     45 }  // namespace mozilla
     46 
     47 #endif  //  mozilla_ErrorHandler_h