X-Git-Url: http://git.kpe.io/?p=ctsim.git;a=blobdiff_plain;f=src%2Fif2img.cpp;h=c3a4bfe801ab80d56c42cd8afc4055db9faaaaec;hp=018e504abf6027fc741ce9fe555d8ea47475515b;hb=207332eec9416d299766abb697312cfd27eb890e;hpb=5cf6874680f80d238bf34535d711dc223813f951 diff --git a/src/if2img.cpp b/src/if2img.cpp index 018e504..c3a4bfe 100644 --- a/src/if2img.cpp +++ b/src/if2img.cpp @@ -9,7 +9,7 @@ ** This is part of the CTSim program ** Copyright (C) 1983-2000 Kevin Rosenberg ** -** $Id: if2img.cpp,v 1.6 2000/06/18 10:27:11 kevin Exp $ +** $Id: if2img.cpp,v 1.7 2000/06/19 17:58:13 kevin Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License (version 2) as @@ -255,7 +255,7 @@ if2img_main (int argc, char *const argv[]) #else cout << "Unknown version number" << endl; #endif - exit(0); + return (0); case O_HELP: case '?': if2img_usage(argv[0]); @@ -282,7 +282,7 @@ if2img_main (int argc, char *const argv[]) pim = new ImageFile (in_file); ImageFile& im = *pim; if (! im.fileRead()) { - sys_error (ERR_SEVERE, "File %s does not exist", in_file); + sys_error (ERR_FATAL, "File %s does not exist", in_file); return (1); } @@ -631,8 +631,8 @@ sdf2d_to_gif (ImageFile& im, char *outfile, int nxcell, int nycell, double densm delete rowp; if ((out = fopen(outfile,"w")) == NULL) { - sys_error(ERR_SEVERE,"Error opening output file %s for writing", outfile); - exit(1); + sys_error(ERR_FATAL, "Error opening output file %s for writing", outfile); + return (1); } gdImageGif(gif,out); fclose(out); @@ -646,6 +646,16 @@ sdf2d_to_gif (ImageFile& im, char *outfile, int nxcell, int nycell, double densm int main (int argc, char *const argv[]) { - return (if2img_main(argc, argv)); + int retval = 1; + + try { + retval = if2img_main(argc, argv); + } catch (exception e) { + cerr << "Exception: " << e.what() << endl; + } catch (...) { + cerr << "Unknown exception" << endl; + } + + return (retval); } #endif