/* * Copyright (c) 1996 Gunther Schadow. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef EXCEPTION_H #define EXCEPTION_H // Error types: // // 1. OS errors `ERROS' text in sys_errlist[errno] -> recover or exit // 2. generic error not directly related to user interface -> recover or exit // 2.1 here: protocol error -> exception/try to recover // 3. user error (like command line parameters wrong, etc) -> print/exit // 4. programming errors (like impossible conditions) -> abort/core // // Except for programming errors, which should dump a core in orter to // be examined, all other errors can be tried to recover from (user errors: // using default values, protocol: going into a defined state, etc.). // // Error/Exception/Warning have two `coordinates' // 1. Message: no message, to logfile, to terminal // 2. Control: normal flow, deviation (return/if), throw excpt., abort process // // Error (to terminal | abort process) e.g. programming error // Error (to terminal | throw exception) e.g. OS error // Error (to logfile | throw exception) e.g. protocol error // Exception (* | throw exception) // Warning (to logfile | normal flow) // Warning (to terminal | normal flow) // Warning (to logfile | deviation) // Warning (to terminal | deviation) // // However, `to terminal' and `to logfile' stand for many different ways of // reporting (e.g. to terminal makes no sense w/o terminal, by mail, logfile // message may be ignored (`a la syslog.conf(5)). # define ERROR(fmt, args...) { fprintf(stderr, fmt "\n" , ## args); exit(1); } # define ERROS(fmt, args...) { fprintf(stderr, fmt "\n" , ## args); exit(1); } # define USERR(fmt, args...) { fprintf(stderr, fmt "\n" , ## args); exit(1); } # define PRERR(fmt, args...) { fprintf(stderr, fmt "\n" , ## args); exit(1); } #endif