mirror of
https://github.com/facebook/sapling.git
synced 2024-10-08 07:49:11 +03:00
8b9261f2a1
Summary: Per discussion with bolinfest, this brings Eden in line with clang-format. This diff was generated with `find . \( -iname '*.cpp' -o -iname '*.h' \) -exec bash -c "yes | arc lint {}" \;` Reviewed By: bolinfest Differential Revision: D6232695 fbshipit-source-id: d54942bf1c69b5b0dcd4df629f1f2d5538c9e28c
48 lines
1.3 KiB
C++
48 lines
1.3 KiB
C++
/*
|
|
* Copyright (c) 2016-present, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
*/
|
|
#include "EdenError.h"
|
|
|
|
namespace facebook {
|
|
namespace eden {
|
|
|
|
EdenError newEdenError(int errorCode, folly::StringPiece message) {
|
|
auto e = EdenError(message.str());
|
|
e.set_errorCode(errorCode);
|
|
return e;
|
|
}
|
|
|
|
EdenError newEdenError(const std::system_error& ex) {
|
|
return newEdenError(ex.code().value(), ex.what());
|
|
}
|
|
|
|
EdenError newEdenError(const std::exception& ex) {
|
|
const auto* edenError = dynamic_cast<const EdenError*>(&ex);
|
|
if (edenError) {
|
|
return *edenError;
|
|
}
|
|
const auto* systemError = dynamic_cast<const std::system_error*>(&ex);
|
|
if (systemError) {
|
|
return newEdenError(*systemError);
|
|
}
|
|
return EdenError(folly::exceptionStr(ex).toStdString());
|
|
}
|
|
|
|
EdenError newEdenError(const folly::exception_wrapper& ew) {
|
|
EdenError err;
|
|
if (!ew.with_exception([&err](const EdenError& ex) { err = ex; }) &&
|
|
!ew.with_exception(
|
|
[&err](const std::system_error& ex) { err = newEdenError(ex); })) {
|
|
err = EdenError(folly::exceptionStr(ew).toStdString());
|
|
}
|
|
return err;
|
|
}
|
|
} // namespace eden
|
|
} // namespace facebook
|