]> git.lyx.org Git - lyx.git/blobdiff - src/support/package.C.in
* src/text2.C: deleteEmptyParagraphMechanism(): fix a crash in
[lyx.git] / src / support / package.C.in
index 6edd7abde4470c8869571460440e1306c5780093..efe19c62727696173219dfe66d18032765d3f468 100644 (file)
@@ -22,6 +22,7 @@
 #include "support/environment.h"
 #include "support/filetools.h"
 #include "support/lstrings.h"
+#include "support/ExceptionMessage.h"
 #include "support/os.h"
 
 #if defined (USE_WINDOWS_PACKAGING)
@@ -369,15 +370,6 @@ string const get_temp_dir()
 }
 
 
-void bail_out()
-{
-#ifndef CXX_GLOBAL_CSTD
-       using std::exit;
-#endif
-       exit(1);
-}
-
-
 // Extracts the absolute path from the foo of "-sysdir foo" or "-userdir foo"
 string const abs_path_from_command_line(string const & command_line)
 {
@@ -440,11 +432,10 @@ string const abs_path_from_binary_name(string const & exe)
        string const abs_binary = get_binary_path(exe);
        if (abs_binary.empty()) {
                // FIXME UNICODE
-               lyxerr << lyx::to_utf8(bformat(_("Unable to determine the path to the "
-                                                "LyX binary from the command line %1$s"),
-                                                lyx::from_utf8(exe)))
-                      << std::endl;
-               bail_out();
+               throw ExceptionMessage(ErrorException,
+                       _("LyX binary not found"),
+                       bformat(_("Unable to determine the path to the LyX binary from the command line %1$s"),
+                               lyx::from_utf8(exe)));
        }
        return abs_binary;
 }
@@ -562,17 +553,16 @@ get_system_support_dir(string const & abs_binary,
        }
 
        // FIXME UNICODE
-       lyxerr << lyx::to_utf8(bformat(_("Unable to determine the system directory "
+       throw ExceptionMessage(ErrorException, _("No system directory"),
+               bformat(_("Unable to determine the system directory "
                                         "having searched\n"
                                         "\t%1$s\n"
                                         "Use the '-sysdir' command line parameter or "
                                         "set the environment variable LYX_DIR_15x to "
                                         "the LyX system directory containing the file "
                                         "`chkconfig.ltx'."),
-                         lyx::from_utf8(searched_dirs_str)))
-              << std::endl;
+                         lyx::from_utf8(searched_dirs_str)));
 
-       bail_out();
        // Keep the compiler happy.
        return string();
 }
@@ -648,11 +638,10 @@ bool check_command_line_dir(string const & dir,
        FileName const abs_path = fileSearch(dir, file);
        if (abs_path.empty()) {
                // FIXME UNICODE
-               lyxerr << lyx::to_utf8(bformat(_("Invalid %1$s switch.\n"
-                                                "Directory %2$s does not contain %3$s."),
-                                 lyx::from_utf8(command_line_switch), lyx::from_utf8(dir),
-                                 lyx::from_utf8(file)))
-                      << std::endl;
+               throw ExceptionMessage(WarningException, _("File not found"), bformat(
+                       _("Invalid %1$s switch.\nDirectory %2$s does not contain %3$s."),
+                       lyx::from_utf8(command_line_switch), lyx::from_utf8(dir),
+                       lyx::from_utf8(file)));
        }
 
        return !abs_path.empty();
@@ -676,10 +665,11 @@ bool check_env_var_dir(string const & dir,
        FileName const abs_path = fileSearch(dir, file);
        if (abs_path.empty()) {
                // FIXME UNICODE
-               lyxerr << lyx::to_utf8(bformat(_("Invalid %1$s environment variable.\n"
-                                                "Directory %2$s does not contain %3$s."),
-                                 lyx::from_utf8(env_var), lyx::from_utf8(dir), lyx::from_utf8(file)))
-                      << std::endl;
+               throw ExceptionMessage(WarningException, _("File not found"), bformat(
+                       _("Invalid %1$s environment variable.\n"
+                               "Directory %2$s does not contain %3$s."),
+                       lyx::from_utf8(env_var), lyx::from_utf8(dir),
+                       lyx::from_utf8(file)));
        }
 
        return !abs_path.empty();
@@ -703,8 +693,8 @@ bool check_env_var_dir(string const & dir,
                docstring const fmt =
                        _("Invalid %1$s environment variable.\n%2$s is not a directory.");
 
-               lyxerr << lyx::to_utf8(bformat(fmt, lyx::from_utf8(env_var), lyx::from_utf8(dir)))
-                      << std::endl;
+               throw ExceptionMessage(WarningException, _("Directory not found"), bformat(
+                       fmt, lyx::from_utf8(env_var), lyx::from_utf8(dir)));
        }
 
        return success;