2018-03-20 23:31:14 +03:00
|
|
|
/*
|
2019-06-20 02:58:25 +03:00
|
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
2018-03-20 23:31:14 +03:00
|
|
|
*
|
2019-06-20 02:58:25 +03:00
|
|
|
* This software may be used and distributed according to the terms of the
|
|
|
|
* GNU General Public License version 2.
|
2018-03-20 23:31:14 +03:00
|
|
|
*/
|
2019-10-11 15:26:59 +03:00
|
|
|
|
2018-03-20 23:31:14 +03:00
|
|
|
#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
|