From 993a58e2f651467c8e20a0a1ef476a2267a9e40b Mon Sep 17 00:00:00 2001 From: Sergei Zimmerman Date: Thu, 23 Oct 2025 23:49:41 +0300 Subject: [PATCH] Revert "libmain: Catch logger exceptions in `handleExceptions`" This reverts commit 90d1ff480590b56db202a20c3927df4bf05e4eac. The initial issue with EPIPE was solved in 9f680874c5aa15304c3ab3b942170a743287f87b. Now this patch does move bad than good by eating up boost::io::format_error that are bugs. (cherry picked from commit 4f5af471fbfc0f551ace552b3f8f184641814313) --- src/libmain/shared.cc | 49 +++++++++++++++++++------------------------ 1 file changed, 22 insertions(+), 27 deletions(-) diff --git a/src/libmain/shared.cc b/src/libmain/shared.cc index 7187e9720..4b36ec98e 100644 --- a/src/libmain/shared.cc +++ b/src/libmain/shared.cc @@ -320,34 +320,29 @@ int handleExceptions(const std::string & programName, std::function fun) std::string error = ANSI_RED "error:" ANSI_NORMAL " "; try { try { - try { - fun(); - } catch (...) { - /* Subtle: we have to make sure that any `interrupted' - condition is discharged before we reach printMsg() - below, since otherwise it will throw an (uncaught) - exception. */ - setInterruptThrown(); - throw; - } - } catch (Exit & e) { - return e.status; - } catch (UsageError & e) { - logError(e.info()); - printError("Try '%1% --help' for more information.", programName); - return 1; - } catch (BaseError & e) { - logError(e.info()); - return e.info().status; - } catch (std::bad_alloc & e) { - printError(error + "out of memory"); - return 1; - } catch (std::exception & e) { - printError(error + e.what()); - return 1; + fun(); + } catch (...) { + /* Subtle: we have to make sure that any `interrupted' + condition is discharged before we reach printMsg() + below, since otherwise it will throw an (uncaught) + exception. */ + setInterruptThrown(); + throw; } - } catch (...) { - /* In case logger also throws just give up. */ + } catch (Exit & e) { + return e.status; + } catch (UsageError & e) { + logError(e.info()); + printError("Try '%1% --help' for more information.", programName); + return 1; + } catch (BaseError & e) { + logError(e.info()); + return e.info().status; + } catch (std::bad_alloc & e) { + printError(error + "out of memory"); + return 1; + } catch (std::exception & e) { + printError(error + e.what()); return 1; }