On Thu, Sep 01, 2016 at 04:15:39PM -0400, Scott Kostyshak wrote: > On Thu, Sep 01, 2016 at 12:48:23AM -0400, Richard Heck wrote: > > On 08/31/2016 05:28 PM, Scott Kostyshak wrote: > > > On Wed, Aug 31, 2016 at 10:08:35PM +0100, Guillaume Munch wrote: > > > > > >> Sounds good to me > > >> (and if there are caveats I am not aware of regarding > > >> exceptions in LyX, I would be curious to know) > > > I have occassionally seen comments that suggest exceptions should be > > > avoided, for example here [1]. > > > > Sometimes people overdo it, and there have been discussions about that. > > But I'm pretty sure that escaping from a deeply nested series of calls > > is a good use. This may even be convered in Exceptional C++. > > OK good to know.
Patch is attached. If no comments, I'll commit in a couple of days. Scott
From 1a374a931b7f72313df61c001f5275480b759c4c Mon Sep 17 00:00:00 2001 From: Scott Kostyshak <skost...@lyx.org> 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 47c9a61..33bc7b5 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.7.4
signature.asc
Description: PGP signature