]> git.lyx.org Git - lyx.git/blobdiff - src/LyX.cpp
Improve error message
[lyx.git] / src / LyX.cpp
index 0e1b19faf664f849a37f6add26f620fbad54e2d8..20c5e83b01de8af67b0296a4ef802dae1d8f0e0a 100644 (file)
@@ -438,17 +438,16 @@ void LyX::prepareExit()
        // do any other cleanup procedures now
        if (package().temp_dir() != package().system_temp_dir()) {
                string const abs_tmpdir = package().temp_dir().absFileName();
-               if (!contains(package().temp_dir().absFileName(), "lyx_tmpdir")) {
+               if (!contains(abs_tmpdir, "lyx_tmpdir")) {
                        docstring const msg =
                                bformat(_("%1$s does not appear like a LyX created temporary directory."),
                                from_utf8(abs_tmpdir));
                        Alert::warning(_("Cannot remove temporary directory"), msg);
                } else {
-                       LYXERR(Debug::INFO, "Deleting tmp dir "
-                               << package().temp_dir().absFileName());
+                       LYXERR(Debug::INFO, "Deleting tmp dir " << abs_tmpdir);
                        if (!package().temp_dir().destroyDirectory()) {
                                LYXERR0(bformat(_("Unable to remove the temporary directory %1$s"),
-                                       from_utf8(package().temp_dir().absFileName())));
+                                       from_utf8(abs_tmpdir)));
                        }
                }
        }
@@ -471,45 +470,39 @@ void LyX::earlyExit(int status)
 
 int LyX::init(int & argc, char * argv[])
 {
-       try {
-               // check for any spurious extra arguments
-               // other than documents
-               for (int argi = 1; argi < argc ; ++argi) {
-                       if (argv[argi][0] == '-') {
-                               lyxerr << to_utf8(
-                                       bformat(_("Wrong command line option `%1$s'. Exiting."),
-                                                       from_utf8(os::utf8_argv(argi)))) << endl;
-                               return EXIT_FAILURE;
-                       }
-               }
-
-               // Initialization of LyX (reads lyxrc and more)
-               LYXERR(Debug::INIT, "Initializing LyX::init...");
-               bool success = init();
-               LYXERR(Debug::INIT, "Initializing LyX::init...done");
-               if (!success)
-                       return EXIT_FAILURE;
-               // Remaining arguments are assumed to be files to load.
-               for (int argi = 1; argi < argc; ++argi)
-                       pimpl_->files_to_load_.push_back(os::utf8_argv(argi));
-
-               if (!use_gui && pimpl_->files_to_load_.empty()) {
-                       lyxerr << to_utf8(_("Missing filename for this operation.")) << endl;
+       // check for any spurious extra arguments
+       // other than documents
+       for (int argi = 1; argi < argc ; ++argi) {
+               if (argv[argi][0] == '-') {
+                       lyxerr << to_utf8(
+                               bformat(_("Wrong command line option `%1$s'. Exiting."),
+                               from_utf8(os::utf8_argv(argi)))) << endl;
                        return EXIT_FAILURE;
                }
+       }
 
-               if (first_start) {
-                       pimpl_->files_to_load_.push_back(
-                               i18nLibFileSearch("examples", "splash.lyx").absFileName());
-               }
+       // Initialization of LyX (reads lyxrc and more)
+       LYXERR(Debug::INIT, "Initializing LyX::init...");
+       bool success = init();
+       LYXERR(Debug::INIT, "Initializing LyX::init...done");
+       if (!success)
+               return EXIT_FAILURE;
 
-               return EXIT_SUCCESS;
+       // Remaining arguments are assumed to be files to load.
+       for (int argi = 1; argi < argc; ++argi)
+               pimpl_->files_to_load_.push_back(os::utf8_argv(argi));
 
-       } catch (exception const &e) {
-               // This can happen _in_theory_ in replaceEnvironmentPath
-               lyxerr << "Caught exception `" << e.what() << "'." << endl;
+       if (!use_gui && pimpl_->files_to_load_.empty()) {
+               lyxerr << to_utf8(_("Missing filename for this operation.")) << endl;
                return EXIT_FAILURE;
        }
+
+       if (first_start) {
+               pimpl_->files_to_load_.push_back(
+                       i18nLibFileSearch("examples", "Welcome.lyx").absFileName());
+       }
+
+       return EXIT_SUCCESS;
 }