]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Rename FatalError class to Fatal
authorJoel Rosdahl <joel@rosdahl.net>
Wed, 19 Aug 2020 05:26:23 +0000 (07:26 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Sat, 22 Aug 2020 13:26:51 +0000 (15:26 +0200)
This makes the naming more consistent with the other exception classes
(Error and Failure).

src/Logging.cpp
src/TemporaryFile.cpp
src/Util.cpp
src/Util.hpp
src/ccache.cpp
src/exceptions.hpp
src/execute.cpp
src/hashutil.cpp

index b8ee4a39552abf421a6fb9d1256df3fe1e390bee..04a6a4b47d4c108293990d26be25ce8bbb494042 100644 (file)
@@ -68,7 +68,7 @@ bool debug_log_enabled = false;
 [[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,
index 88814fa995cee3c00c6fe7ce501b642425059701..285654f48f5acbad4c63b8089ab993b392705968 100644 (file)
@@ -63,13 +63,12 @@ TemporaryFile::TemporaryFile(string_view path_prefix)
   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));
   }
 
index 5c60c55258a8e383cb68b6485933a1893317b121..7550493206f93d150f20342955d99c1add31160d 100644 (file)
@@ -661,8 +661,7 @@ get_home_directory()
     }
   }
 #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*
index 44ad8599bb3e3fcb0029e8c1ab79ae5171cd5d18..712f06ad912c76d7eecce743286d037797b40818 100644 (file)
@@ -195,7 +195,7 @@ void get_level_1_files(const std::string& dir,
                        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();
 
index 734dae6a68f86a47d5199372841773628beb8a16..386594d820594ebcfc1cb6ae09671f19a2cb45fd 100644 (file)
@@ -164,7 +164,7 @@ add_prefix(const Context& ctx, Args& args, const std::string& prefix_command)
   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);
@@ -1707,10 +1707,10 @@ find_compiler(Context& ctx, const char* const* argv)
 
   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);
   }
@@ -1977,7 +1977,7 @@ cache_compilation(int argc, const char* const* argv)
     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));
   }
 }
 
index 3434af63be815296dd7313993e3103f42e67194e..defb1205c1bc83a691d1e6fb176ca6a5e12a9670 100644 (file)
@@ -38,7 +38,7 @@ class ErrorBase : public std::runtime_error
 
 // 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:
@@ -59,24 +59,24 @@ inline Error::Error(T&&... args)
 {
 }
 
-// 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)...))
 {
 }
index 7b647b7b1f58e5687ea7f8c7a9a5953277aa5711..c650c8525e7e55be0aa5de5a34feffcb84ae4df8 100644 (file)
@@ -166,7 +166,7 @@ execute(const char* const* argv, Fd&& fd_out, Fd&& fd_err, pid_t* pid)
   }
 
   if (*pid == -1) {
-    throw FatalError("Failed to fork: {}", strerror(errno));
+    throw Fatal("Failed to fork: {}", strerror(errno));
   }
 
   if (*pid == 0) {
@@ -183,7 +183,7 @@ execute(const char* const* argv, Fd&& fd_out, Fd&& fd_err, pid_t* pid)
 
   int status;
   if (waitpid(*pid, &status, 0) != *pid) {
-    throw FatalError("waitpid failed: {}", strerror(errno));
+    throw Fatal("waitpid failed: {}", strerror(errno));
   }
 
   {
index c8d13aaa58eced3a9b5ac9b9d8d9081725821d48..67f6a5b2fda9a153f13d8a7c0b65104b60901686 100644 (file)
@@ -466,12 +466,12 @@ hash_command_output(Hash& hash,
 #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) {