changeset 7042:de713a31cbd3

standardized and clarified error messages
author Alain Mazy <am@orthanc.team>
date Tue, 11 Aug 2026 12:37:18 +0200
parents dbad0dbcbbc3
children cb558bd6ba67
files OrthancFramework/Sources/SystemToolbox.cpp
diffstat 1 files changed, 24 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancFramework/Sources/SystemToolbox.cpp	Mon Aug 10 16:53:01 2026 +0200
+++ b/OrthancFramework/Sources/SystemToolbox.cpp	Tue Aug 11 12:37:18 2026 +0200
@@ -227,8 +227,8 @@
   {
     if (!IsRegularFile(path))
     {
-      throw OrthancException(ErrorCode_RegularFileExpected,
-                             "The path does not point to a regular file: " + PathToUtf8(path), log);
+      throw OrthancException(ErrorCode_RegularFileExpected, 
+                             "Not a regular file or file not found: " + PathToUtf8(path), log);
     }
 
     try
@@ -258,11 +258,13 @@
     }
     catch (boost::filesystem::filesystem_error&)
     {
-      throw OrthancException(ErrorCode_InexistentFile);
+      throw OrthancException(ErrorCode_InexistentFile, 
+                             "File not found: " + PathToUtf8(path));
     }
     catch (...)  // To catch "std::system_error&" in C++11
     {
-      throw OrthancException(ErrorCode_InexistentFile);
+      throw OrthancException(ErrorCode_InexistentFile, 
+                             "File not found: " + PathToUtf8(path));
     }
   }
 
@@ -273,8 +275,8 @@
   {
     if (!IsRegularFile(path))
     {
-      throw OrthancException(ErrorCode_RegularFileExpected,
-                             "The path does not point to a regular file: " + PathToUtf8(path));
+      throw OrthancException(ErrorCode_RegularFileExpected, 
+                             "Not a regular file or file not found: " + PathToUtf8(path));
     }
 
     try
@@ -283,7 +285,8 @@
       f.open(path, std::ifstream::in | std::ifstream::binary);
       if (!f.good())
       {
-        throw OrthancException(ErrorCode_InexistentFile);
+        throw OrthancException(ErrorCode_InexistentFile,
+                               "File not found: " + PathToUtf8(path));
       }
 
       bool full = true;
@@ -314,11 +317,13 @@
     }
     catch (boost::filesystem::filesystem_error&)
     {
-      throw OrthancException(ErrorCode_InexistentFile);
+      throw OrthancException(ErrorCode_InexistentFile, 
+                             "File not found: " + PathToUtf8(path));
     }
     catch (...)  // To catch "std::system_error&" in C++11
     {
-      throw OrthancException(ErrorCode_InexistentFile);
+      throw OrthancException(ErrorCode_InexistentFile, 
+                             "File not found: " + PathToUtf8(path));
     }
   }
 
@@ -414,7 +419,8 @@
       }
       else
       {
-        throw OrthancException(ErrorCode_RegularFileExpected);
+        throw OrthancException(ErrorCode_RegularFileExpected, 
+                               "Not a regular file or file not found: " + PathToUtf8(path));
       }
     }
   }
@@ -428,11 +434,13 @@
     }
     catch (boost::filesystem::filesystem_error&)
     {
-      throw OrthancException(ErrorCode_InexistentFile);
+      throw OrthancException(ErrorCode_InexistentFile,
+                             "File not found: " + PathToUtf8(path));
     }
     catch (...)  // To catch "std::system_error&" in C++11
     {
-      throw OrthancException(ErrorCode_InexistentFile);
+      throw OrthancException(ErrorCode_InexistentFile, 
+                             "File not found: " + PathToUtf8(path));
     }
   }
 
@@ -1068,16 +1076,16 @@
     
     if (!IsRegularFile(path))
     {
-      throw OrthancException(ErrorCode_RegularFileExpected,
-                             "The path does not point to a regular file: " + SystemToolbox::PathToUtf8(path));
+      throw OrthancException(ErrorCode_RegularFileExpected, 
+                             "Not a regular file or file not found: " + PathToUtf8(path));
     }
 
     boost::filesystem::ifstream f;
     f.open(path, std::ifstream::in | std::ifstream::binary);
     if (!f.good())
     {
-      throw OrthancException(ErrorCode_InexistentFile, 
-                             "File not found: " + SystemToolbox::PathToUtf8(path));
+      throw OrthancException(ErrorCode_InexistentFile,
+                             "File not found: " + PathToUtf8(path));
     }
 
     uint64_t fileSize = static_cast<uint64_t>(GetStreamSize(f));