mirror of
https://github.com/facebook/sapling.git
synced 2024-10-10 08:47:12 +03:00
fbdb46f5cb
Reviewed By: chadaustin Differential Revision: D17872966 fbshipit-source-id: cd60a364a2146f0dadbeca693b1d4a5d7c97ff63
36 lines
943 B
C++
36 lines
943 B
C++
/*
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This software may be used and distributed according to the terms of the
|
|
* GNU General Public License version 2.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <system_error>
|
|
|
|
namespace facebook {
|
|
namespace eden {
|
|
|
|
/**
|
|
* Return true if this exception contains an errno value in ex.code().value()
|
|
*/
|
|
inline bool isErrnoError(const std::system_error& ex) {
|
|
// std::generic_category is the correct category to represent errno values.
|
|
// However folly/Exception.h unfortunately throws errno values as
|
|
// std::system_category for now.
|
|
return (
|
|
ex.code().category() == std::generic_category() ||
|
|
ex.code().category() == std::system_category());
|
|
}
|
|
|
|
/**
|
|
* Return true if this exception is equivalent to an ENOENT error code.
|
|
*/
|
|
inline bool isEnoent(const std::system_error& ex) {
|
|
return isErrnoError(ex) && ex.code().value() == ENOENT;
|
|
}
|
|
|
|
} // namespace eden
|
|
} // namespace facebook
|