[[noreturn]] void
print_fatal_error_and_exit()
{
- // Note: Can't throw FatalError since that would lead to recursion.
+ // Note: Can't throw Fatal since that would lead to recursion.
fmt::print(stderr,
"ccache: error: Failed to write to {}: {}\n",
logfile_path,
if (!initialize(path_prefix) && errno == ENOENT) {
auto dir = Util::dir_name(path);
if (!Util::create_dir(dir)) {
- throw FatalError(
- "Failed to create directory {}: {}", dir, strerror(errno));
+ throw Fatal("Failed to create directory {}: {}", dir, strerror(errno));
}
initialize(path_prefix);
}
if (!fd) {
- throw FatalError(
+ throw Fatal(
"Failed to create temporary file for {}: {}", path, strerror(errno));
}
}
}
#endif
- throw FatalError(
- "Could not determine home directory from $HOME or getpwuid(3)");
+ throw Fatal("Could not determine home directory from $HOME or getpwuid(3)");
}
const char*
const ProgressReceiver& progress_receiver,
std::vector<std::shared_ptr<CacheFile>>& files);
-// Return the current user's home directory, or throw `FatalError` if it can't
+// Return the current user's home directory, or throw `Fatal` if it can't
// be determined.
std::string get_home_directory();
for (const auto& word : Util::split_into_strings(prefix_command, " ")) {
std::string path = find_executable(ctx, word, CCACHE_NAME);
if (path.empty()) {
- throw FatalError("{}: {}", word, strerror(errno));
+ throw Fatal("{}: {}", word, strerror(errno));
}
prefix.push_back(path);
std::string compiler = find_executable(ctx, base, CCACHE_NAME);
if (compiler.empty()) {
- throw FatalError("Could not find compiler \"{}\" in PATH", base);
+ throw Fatal("Could not find compiler \"{}\" in PATH", base);
}
if (compiler == argv[0]) {
- throw FatalError(
+ throw Fatal(
"Recursive invocation (the name of the ccache binary must be \"{}\")",
CCACHE_NAME);
}
log("Executing {}", Util::format_argv_for_logging(execv_argv.data()));
ctx.reset(); // Dump debug logs last thing before executing.
execv(execv_argv[0], const_cast<char* const*>(execv_argv.data()));
- throw FatalError("execv of {} failed: {}", execv_argv[0], strerror(errno));
+ throw Fatal("execv of {} failed: {}", execv_argv[0], strerror(errno));
}
}
// Throw an Error to indicate a potentially non-fatal error that may be caught
// and handled by callers. An uncaught Error that reaches the top level will be
-// treated similar to FatalError.
+// treated similar to Fatal.
class Error : public ErrorBase
{
public:
{
}
-// Throw a FatalError to make ccache print the error message to stderr and exit
+// Throw a Fatal to make ccache print the error message to stderr and exit
// with a non-zero exit code.
-class FatalError : public ErrorBase
+class Fatal : public ErrorBase
{
public:
// Special case: If given only one string, don't parse it as a format string.
- FatalError(const std::string& message);
+ Fatal(const std::string& message);
// `args` are forwarded to `fmt::format`.
- template<typename... T> inline FatalError(T&&... args);
+ template<typename... T> inline Fatal(T&&... args);
};
-inline FatalError::FatalError(const std::string& message) : ErrorBase(message)
+inline Fatal::Fatal(const std::string& message) : ErrorBase(message)
{
}
template<typename... T>
-inline FatalError::FatalError(T&&... args)
+inline Fatal::Fatal(T&&... args)
: ErrorBase(fmt::format(std::forward<T>(args)...))
{
}
}
if (*pid == -1) {
- throw FatalError("Failed to fork: {}", strerror(errno));
+ throw Fatal("Failed to fork: {}", strerror(errno));
}
if (*pid == 0) {
int status;
if (waitpid(*pid, &status, 0) != *pid) {
- throw FatalError("waitpid failed: {}", strerror(errno));
+ throw Fatal("waitpid failed: {}", strerror(errno));
}
{
#else
int pipefd[2];
if (pipe(pipefd) == -1) {
- throw FatalError("pipe failed: {}", strerror(errno));
+ throw Fatal("pipe failed: {}", strerror(errno));
}
pid_t pid = fork();
if (pid == -1) {
- throw FatalError("fork failed: {}", strerror(errno));
+ throw Fatal("fork failed: {}", strerror(errno));
}
if (pid == 0) {