Răsfoiți Sursa

Extended FileOperationException class

- added file path parameter to constructor to
provide detailed information in case this exception
 is being thrown
Patrick 4 ani în urmă
părinte
comite
281bb8e36d
1 a modificat fișierele cu 11 adăugiri și 1 ștergeri
  1. 11 1
      source/exception/FileOperationException.hpp

+ 11 - 1
source/exception/FileOperationException.hpp

@@ -11,14 +11,24 @@
 #define FILE_OPERATION_EXCEPTION_HPP
 
 #include <exception>
+#include <string>
 
 namespace ls_std {
   class FileOperationException : public std::exception {
     public:
 
+      explicit FileOperationException(std::string _filePath):
+      filePath(std::move(_filePath))
+      {}
+
       const char *what() const noexcept override {
-        return "file operation failed...";
+        const std::string errorMessage = "file operation failed!\nfile: " + this->filePath;
+        return std::move(errorMessage.c_str());
       }
+
+    private:
+
+      std::string filePath {};
   };
 }