/****************************************************************************** * * Copyright (C) 2010 by * * CGTD ICARE * Université des Sciences et Technologies de Lille 1 * Polytech'Lille - Bâtiment Eydoux - Bureau E207 * Avenue Paul Langevin * 59650 Villeneuve d'Ascq Cedex * France * * Description : * ------------- * Generic Exception Manager * * Author : * -------- * * CGTD-ICARE/UDEV Nicolas PASCAL * * License : * --------- * * This file must be used under the terms of the CeCILL. * This source file is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms * are also available at * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt * * History : * -------- * * v0.0.0 : 04/01/2010 * - creation * *****************************************************************************/ #ifndef GENERIC_EXCEPTION_H #define GENERIC_EXCEPTION_H #include using namespace std; #include "string_tools.h" /** * @class g_exception generic_exception.h * @brief Generic exception class */ class g_exception : public exception { /** file where the exception has been raised */ string file; /** line where the exception has been raised */ long line; /** exception message */ string msg; public: /** * @brief constructor * @param file file of the exception * @param line line of the exception * @param msg message of the exception */ g_exception( const char* file, long line, string msg = "" ) : file(file) , line(line) , msg(msg) { }; /** * @brief destructor */ virtual ~g_exception() throw() { }; /** * @brief print the message of the exception * @return the description of the exception */ virtual const char * what() const throw() { string s ( file + "[" + to_string ( line ) + "] : " + msg ); return s.c_str(); } }; #endif