1 /* 2 GuidoAR Library 3 Copyright (C) 2008 Grame 4 5 This library is free software; you can redistribute it and/or 6 modify it under the terms of the GNU Lesser General Public 7 License as published by the Free Software Foundation; either 8 version 2.1 of the License, or (at your option) any later version. 9 10 This library is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 Lesser General Public License for more details. 14 15 You should have received a copy of the GNU Lesser General Public 16 License along with this library; if not, write to the Free Software 17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 19 Grame Research Laboratory, 9 rue du Garet, 69001 Lyon - France 20 research@grame.fr 21 22 */ 23 24 #ifndef __exceptions__ 25 #define __exceptions__ 26 27 //______________________________________________________________________________ 28 typedef struct TException { 29 TExceptionTException30 TException(int n, const char* s, const char* f, int ln) 31 : num(n), msg(s), file(f), line(ln) {} 32 33 const int num; // the exception number 34 const char* msg; // the message associated to the exception 35 const char* file; // the file where the exception occured 36 const int line; // the line number within the file 37 }TException; 38 39 //______________________________________________________________________________ 40 // a macro to automatically catch the file name and line number 41 #define eMsg(n) kExceptionMsg[n] 42 #define newMsgException(n,msg) TException(n,msg,__FILE__,__LINE__) 43 #define newException(n) TException(n,eMsg(n),__FILE__,__LINE__) 44 45 //______________________________________________________________________________ 46 // exceptions definitions 47 enum ExceptionNum { 48 kNoException, // no exception - shouldn't be triggered 49 kUndefinedCompOperation, // undefined composition operator called 50 kNullValue, // got an unexpected null value 51 kNullEnvironment, // got a null environment 52 kNullIdent, // got a null identificator within a lambda abstraction 53 kNullBody, // got a null body within a lambda abstraction 54 kMissingArgument // an expression argument is missing 55 }; 56 57 extern const char* kExceptionMsg[]; // and the associates messages 58 59 #endif 60