/* * Copyright (c) 1995, 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 PG_EXCEPTION_H_ #define PG_EXCEPTION_H_ #include #pragma interface #include #ifdef USE_EXCEPTIONS #error Exceptions not yet! :-( #include #define E_FATAL ExcpFatal #define E_ERROR ExcpError #define E_ERROS ExcpErrOS #define E_PARSE ExcpParse #define E_PROTO ExcpProto #define E_EOF ExcpEOF class Excp: public exception { public: Excp(const char *org, const char *msg, ...); virtual ~Excp() { } } #define NEW_EXCP(name) class name : public exception { public: name (const char *org, const char *msg, ...) : Excp(const char *org, const char *msg, ...) { } virtual ~name() { } } #define EXCEPTION(typ, msg, args...) \ throw typ (__PRETTY_FUNCTION__, msg , ##args); #else #include #define E_FATAL 0 #define E_ERROR 1 #define E_ERROS 2 #define E_PARSE 3 #define E_PROTO 4 #define E_EOF 5 #define E_MAX 6 typedef void (*exception_handler_t) (int typ, const char *msg); __BEGIN_DECLS void exception(int typ, const char *org, const char *msg, ...) __attribute__ ((__noreturn__)); void exception_handler(int typ, exception_handler_t hdl); __END_DECLS #define EXCEPTION(typ, msg, args...) \ exception(typ, __PRETTY_FUNCTION__, msg , ##args); #define FATAL(msg, args...) \ exception(E_FATAL, __PRETTY_FUNCTION__, msg , ##args) #define ERROR(msg, args...) \ exception(E_ERROR, __PRETTY_FUNCTION__, msg , ##args) #define ERROS(msg, args...) \ exception(E_ERROS, __PRETTY_FUNCTION__, msg , ##args) #define EPARSE(msg, args...) \ exception(E_PARSE, __PRETTY_FUNCTION__, msg , ##args) #define EPROTO(msg, args...) \ exception(E_PARSE, __PRETTY_FUNCTION__, msg , ##args) #define EEOF(msg, args...) \ exception(E_EOF, __PRETTY_FUNCTION__, msg , ##args) #define EXCPT(typ) \ exception(typ, __PRETTY_FUNCTION__, NULL) #endif #endif /* !PG_EXCEPTION_H_ */