[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi-commits] [lmi] master 14d582d 7/7: Trap exceptions from filesystem

From: Greg Chicares
Subject: [lmi-commits] [lmi] master 14d582d 7/7: Trap exceptions from filesystem library
Date: Wed, 7 Oct 2020 19:36:14 -0400 (EDT)

branch: master
commit 14d582d499d7487ba10e81d9f2213d876b102d78
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>

    Trap exceptions from filesystem library
    Prevent this problem:
    $wine ./lmi_wx_shared --ash_nazg --data_path=/opt/lmi/data
    boost::filesystem::path: invalid name "Z:" in path: \
    Alarum: Instantiation failed.
    [configurable_settings.cpp : 193]
    (terminates with nonzero return code)
    Instead, show the filesystem error in a messagebox, and let the end user
    dismiss it and continue normally.
    Further refinements are certainly possible, but a forcible exit with no
    workaround had to be prevented now. It seems better to wait until the
    boost library is replaced by std::filesystem before any further change.
    One obvious alternative is to store a generic path and convert to the
    "native" form, internally, for actual use.
 configurable_settings.cpp | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/configurable_settings.cpp b/configurable_settings.cpp
index 8316b05..288284a 100644
--- a/configurable_settings.cpp
+++ b/configurable_settings.cpp
@@ -146,11 +146,25 @@ configurable_settings::configurable_settings()
-    default_input_filename_ = 
-    print_directory_        = fs::system_complete(print_directory_       
+    try
+        {
+        default_input_filename_ = 
+// Performing this test seems like a good idea, but it would flag
+// an empty path as an error.
+//      validate_filepath(default_input_filename_, "Default input file");
+        }
+    catch(...)
+        {
+        report_exception();
+        // Silently replace invalid path with an empty string,
+        // which will produce an informative diagnostic when
+        // a default is needed.
+        default_input_filename_ = {};
+        }
+        print_directory_ = fs::system_complete(print_directory_).string();
         validate_directory(print_directory_, "Print directory");

reply via email to

[Prev in Thread] Current Thread [Next in Thread]