]> git.lyx.org Git - features.git/commitdiff
Exit with error if child exits with error (#10188)
authorScott Kostyshak <skostysh@lyx.org>
Fri, 2 Sep 2016 21:10:41 +0000 (17:10 -0400)
committerScott Kostyshak <skostysh@lyx.org>
Fri, 2 Sep 2016 22:24:14 +0000 (18:24 -0400)
Before, it could have been the case that

  lyx -e pdf2 file.lyx

had exit code 0 even though file.lyx includes a file that exits with
error. If compiled in the GUI a warning was given, but from the
command line exit code it would seem there was no problem. The exit
code for this case is now non-zero and the word "Warning" is now
removed from the message because it should be treated as an error.

An exception is thrown from InsetInclude and is caught in
Buffer::makeLaTeXFile() and added to the error list.

The (similar) use case at #8840 is also fixed by this commit.

src/insets/InsetInclude.cpp

index 47c9a613436cb262818da8d226178b8c81b408c4..33bc7b5b75bccd3544d6bd1c4b51fd99383fcb57 100644 (file)
@@ -62,6 +62,7 @@
 #include "support/lstrings.h" // contains
 #include "support/lyxalgo.h"
 #include "support/mutex.h"
+#include "support/ExceptionMessage.h"
 
 #include "support/bind.h"
 
@@ -702,7 +703,7 @@ void InsetInclude::latex(otexstream & os, OutputParams const & runparams) const
                                onlyPath().absFileName(), runparams, Buffer::OnlyBody)) {
                        if (!runparams.silent) {
                                docstring msg = bformat(_("Included file `%1$s' "
-                                       "was not exported correctly.\nWarning: "
+                                       "was not exported correctly.\n "
                                        "LaTeX export is probably incomplete."),
                                        included_file.displayName());
                                ErrorList const & el = tmp->errorList("Export");
@@ -710,7 +711,8 @@ void InsetInclude::latex(otexstream & os, OutputParams const & runparams) const
                                        msg = bformat(from_ascii("%1$s\n\n%2$s\n\n%3$s"),
                                                msg, el.begin()->error,
                                                el.begin()->description);
-                               Alert::warning(_("Export failure"), msg);
+                               throw ExceptionMessage(ErrorException, _("Error: "),
+                                                      msg);
                        }
                }
                runparams.encoding = oldEnc;
@@ -727,14 +729,15 @@ void InsetInclude::latex(otexstream & os, OutputParams const & runparams) const
 
                        if (!success && !runparams.silent) {
                                docstring msg = bformat(_("Included file `%1$s' "
-                                               "was not exported correctly.\nWarning: "
+                                               "was not exported correctly.\n "
                                                "LaTeX export is probably incomplete."),
                                                included_file.displayName());
                                if (!el.empty())
                                        msg = bformat(from_ascii("%1$s\n\n%2$s\n\n%3$s"),
                                                        msg, el.begin()->error,
                                                        el.begin()->description);
-                               Alert::warning(_("Export failure"), msg);
+                               throw ExceptionMessage(ErrorException, _("Error: "),
+                                                      msg);
                        }
                }
        } else {