From 1a374a931b7f72313df61c001f5275480b759c4c Mon Sep 17 00:00:00 2001 From: Scott Kostyshak Date: Fri, 2 Sep 2016 17:10:41 -0400 Subject: [PATCH] Exit with error if child exits with error (#10188) 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 | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/insets/InsetInclude.cpp b/src/insets/InsetInclude.cpp index 47c9a61343..33bc7b5b75 100644 --- a/src/insets/InsetInclude.cpp +++ b/src/insets/InsetInclude.cpp @@ -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 { -- 2.39.2