Quellcode durchsuchen

Improve FileOperationException usage in project classes

Patrick-Christopher Mattulat vor 1 Jahr
Ursprung
Commit
67289d4454

+ 8 - 8
source/ls-std/io/File.cpp

@@ -3,7 +3,7 @@
  * Company:         Lynar Studios
  * E-Mail:          webmaster@lynarstudios.com
  * Created:         2020-08-15
- * Changed:         2023-02-06
+ * Changed:         2023-02-07
  *
  * */
 
@@ -75,7 +75,7 @@ void ls::std::io::File::createNewFile()
   }
   else
   {
-    throw ls::std::core::FileOperationException{};
+    throw ls::std::core::FileOperationException{"operation: create new file"};
   }
 }
 
@@ -184,7 +184,7 @@ void ls::std::io::File::makeDirectory()
 {
   if (!ls::std::io::File::_makeDirectory(this->absoluteFilePath))
   {
-    throw ls::std::core::FileOperationException{};
+    throw ls::std::core::FileOperationException{"operation: create directory"};
   }
 }
 
@@ -202,7 +202,7 @@ void ls::std::io::File::makeDirectories()
     {
       if (!ls::std::io::File::_makeDirectory(currentHierarchy))
       {
-        throw ls::std::core::FileOperationException{}; // TODO: add missing test
+        throw ls::std::core::FileOperationException{"operation: create directory"}; // TODO: add missing test
       }
     }
 
@@ -330,7 +330,7 @@ bool ls::std::io::File::_exists(const ::std::string &_path)
 
   if (getcwd(buffer, sizeof(buffer)) == nullptr)
   {
-    throw ls::std::core::FileOperationException{};
+    throw ls::std::core::FileOperationException{"operation: get working directory"};
   }
   else
   {
@@ -351,7 +351,7 @@ bool ls::std::io::File::_exists(const ::std::string &_path)
 
   if (!GetCurrentDirectory(MAX_PATH, buffer))
   {
-    throw ls::std::core::FileOperationException{};
+    throw ls::std::core::FileOperationException{"operation: get working directory"};
   }
   else
   {
@@ -431,7 +431,7 @@ bool ls::std::io::File::_isReadableUnix(const ::std::string &_path)
   }
   else
   {
-    throw ls::std::core::FileOperationException{};
+    throw ls::std::core::FileOperationException{"operation: fetch permissions"};
   }
 
   return readable;
@@ -453,7 +453,7 @@ bool ls::std::io::File::_isReadableWindows(const ::std::string &_path)
   }
   else
   {
-    throw ls::std::core::FileOperationException{};
+    throw ls::std::core::FileOperationException{"operation: fetch permissions"};
   }
 
   return readable;

+ 1 - 1
source/ls-std/io/FileOutputStream.cpp

@@ -44,7 +44,7 @@ bool ls::std::io::FileOutputStream::write(const ls::std::core::type::byte_field
   }
   else
   {
-    throw ls::std::core::FileOperationException{};
+    throw ls::std::core::FileOperationException{"operation: write"};
   }
 
   return succeeded;

+ 1 - 1
source/ls-std/io/FileReader.cpp

@@ -29,7 +29,7 @@ ls::std::core::type::byte_field ls::std::io::FileReader::read()
 
   if (inputStream.fail())
   {
-    throw ls::std::core::FileOperationException{};
+    throw ls::std::core::FileOperationException{"operation: read"};
   }
 
   inputStream.close();

+ 0 - 1
source/ls-std/io/FileWriter.cpp

@@ -9,7 +9,6 @@
 
 #include <fstream>
 #include <ls-std/core/exception/FileNotFoundException.hpp>
-#include <ls-std/core/exception/FileOperationException.hpp>
 #include <ls-std/io/FileWriter.hpp>
 
 ls::std::io::FileWriter::FileWriter(ls::std::io::File &_file) : ls::std::core::Class("FileWriter"), file(_file)