#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)
}
-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)
{
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;
}
}
// 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();
}
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();
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();
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;