From 5aec670621f4e9fd16f863a4a774d04a80d5eb62 Mon Sep 17 00:00:00 2001 From: "Markus F.X.J. Oberhumer" Date: Wed, 28 Feb 2001 00:33:14 +0000 Subject: [PATCH] Catch std::bad_alloc and print a better error message in this case. committer: mfx 983320394 +0000 --- src/work.cpp | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/work.cpp b/src/work.cpp index 56c7b75b..8f0cd1b7 100644 --- a/src/work.cpp +++ b/src/work.cpp @@ -268,29 +268,33 @@ void do_files(int i, int argc, char *argv[]) try { do_one_file(iname,oname); } catch (const Exception &e) { + unlink_ofile(oname); if (opt->verbose >= 2 || (opt->verbose >= 1 && !e.isWarning())) printErr(iname,&e); - unlink_ofile(oname); } catch (const Error &e) { + unlink_ofile(oname); printErr(iname,&e); - unlink_ofile(oname); e_exit(EXIT_ERROR); - //throw; + } catch (const std::bad_alloc &e) { + unlink_ofile(oname); + printErr(iname,"out of memory"); + e_exit(EXIT_ERROR); + } catch (const std::bad_alloc *e) { + unlink_ofile(oname); + printErr(iname,"out of memory"); + e_exit(EXIT_ERROR); } catch (const exception &e) { + unlink_ofile(oname); printUnhandledException(iname,&e); - unlink_ofile(oname); e_exit(EXIT_ERROR); - //throw; } catch (const exception *e) { + unlink_ofile(oname); printUnhandledException(iname,e); - unlink_ofile(oname); e_exit(EXIT_ERROR); - //throw; } catch (...) { - printUnhandledException(iname,NULL); unlink_ofile(oname); + printUnhandledException(iname,NULL); e_exit(EXIT_ERROR); - //throw; } #if defined(WITH_MSS)