cfl_exception.h

Go to the documentation of this file.
00001 /** @file cfl_exception.h Class Exception */
00002 
00003 /* FAU Discrete Event Systems Library (libfaudes)
00004 
00005    Copyright (C) 2006  Bernd Opitz
00006    Exclusive copyright is granted to Klaus Schmidt
00007 
00008    This library is free software; you can redistribute it and/or
00009    modify it under the terms of the GNU Lesser General Public
00010    License as published by the Free Software Foundation; either
00011    version 2.1 of the License, or (at your option) any later version.
00012 
00013    This library is distributed in the hope that it will be useful,
00014    but WITHOUT ANY WARRANTY; without even the implied warranty of
00015    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016    Lesser General Public License for more details.
00017 
00018    You should have received a copy of the GNU Lesser General Public
00019    License along with this library; if not, write to the Free Software
00020    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
00021 
00022 
00023 #ifndef FAUDES_EXCEPTION_H
00024 #define FAUDES_EXCEPTION_H
00025 
00026 #include "cfl_definitions.h"
00027 #include "cfl_helper.h"
00028 #include <exception>
00029 #include <string>
00030 
00031 namespace faudes {
00032 
00033 /**
00034  * Faudes exception class. libFAUDES uses the C++ exception mechanism to
00035  * report errors on file IO and all sorts of invalid arguments. Members are
00036  *
00037  * @param Function
00038  *   Function name (where did the exception happen)
00039  * @param Description
00040  *   Detailed description (human readable comment)
00041  * @param ErrorId
00042  *   Error id (numeric id, see below)
00043 
00044  * Define the compiletime option FAUDES_DEBUG_EXCEPTIONS  
00045  * to enable verbose output when exceptions are thrown, including those that are catched
00046  * on another level. Define the compiletime option FAUDES_CHECKED to turn
00047  * on argument validation on both internal and user functions.   
00048  *
00049  *
00050  *
00051  * (File-) System Errors
00052  *
00053  *    - 0: Error not defined or no error id given
00054  *    - 1: ios::failure thrown while opening/reading/seeking file
00055  *    - 2: ios::failure thrown while opening/writing file
00056  *    - 3: error on in systemcall (eg dot)
00057  *
00058  * Symboltable Errors
00059  *
00060  *   - 40: SymbolTable - overflow
00061  *   - 41: SymbolTable - attempt to insert or set name which already exists
00062  *   - 42: SymbolTable - attempt to insert or set index which already exists
00063  *   - 43: SymbolTable - attempt to insert or set invalid name 
00064  *
00065  * Runtime interface error
00066  *
00067  *   - 45: Registry - attempt to insert invalid entry
00068  *   - 46: Registry - attempt to access non existent entry
00069  *   - 47: Registry - parameter index out of range
00070  *   - 48: Registry - type check error
00071  *   - 49: Registry - function execution error
00072  *
00073  * Token IO Errors
00074  *
00075  *   - 50: TokenReader: token mismatch 
00076  *   - 51: TokenReader: label not found
00077  *   - 52: TokenReader: unbalanced SeekEnd() 
00078  *
00079  * Container Classes Errors
00080  *
00081  *   - 60: IndexSet:   index not found (eg. when accessing attribute)
00082  *   - 61: IndexSet:   attempt to insert invalid index 0
00083  *   - 62: BaseSet:    invalid iterator
00084  *   - 63: BaseSet:    invalid attribute access
00085  *   - 65: NameSet:    referring to index with no symbolic name
00086  *   - 66: NameSet:    referring unknown symbolic name
00087  *   - 67: NameSet:    symboltable mismatch
00088  *   - 68: TransSet:   order mismatch
00089  *   - 69: BaseVector: invalid index
00090  *
00091  * Core Generator Classes Errors
00092  *
00093  *   - 80: Generator: reading invalid stateset 
00094  *   - 85: Generator: reading invalid transition set 
00095  *   - 88: Generator: symbol table mismatch
00096  *   - 89: Generator: referring to unkown event name
00097  *   - 90: Generator: referring to unkown state name
00098  *   - 91: Generator: setting transition/initial/marked property for unkown state
00099  *   - 92: Generator: initial state does not exist uniquely
00100  *   - 95: Generator: transition referring to unknown states/event
00101  *   - 96: Generator: source must not match destination
00102  *   - 99: Generator: internal validity check failed
00103  *
00104  *  
00105  * Generator Operation Errors
00106  *
00107  *   - 100: Alphabet mismatch
00108  *   - 101: Nondeterministic argument
00109  *   - 110: Break on application request
00110  *   - 1xx  See respective functions
00111  *   - 2xx  See respective functions
00112  *
00113  * Exception ids between 300 and 999 are used by LRT plugins. 
00114  *
00115  *   - 55x IODevice
00116  *
00117  */
00118 class Exception : public std::exception {
00119   public:
00120     /**
00121      * Constructor
00122      *
00123      * Writes an error message on stderr and throws an exception.
00124      * 
00125      * @param rFunctionName
00126      *   Function name (where did the exception happen)
00127      * @param rDescription
00128      *   Detailed error description
00129      * @param errorId
00130      *   Error id
00131      * @param mute
00132      *   when true, mute console output
00133                  *   (this is meant for threaded applications where console out may be an issue)
00134      */
00135     explicit Exception(const std::string& rFunctionName, 
00136            const std::string& rDescription, unsigned int errorId, bool mute=false);
00137 
00138     /** Destructor */
00139     virtual ~Exception() throw();
00140 
00141     /** Returns Function */
00142     virtual const char* Where() const throw();
00143 
00144     /** Returns error description */
00145     virtual const char* What() const throw();
00146 
00147     /** Returns error description */
00148     virtual const char* Message() const throw();
00149 
00150     /** Returns error id */
00151     virtual unsigned int Id() const throw();
00152 
00153   private:
00154     /** Function name */
00155     std::string mFunctionName;
00156 
00157     /** Error description */
00158     std::string mDescription;
00159 
00160     /** Error message */
00161     std::string mMessage;
00162 
00163     /** Error id */
00164     unsigned int mErrorId;
00165 };
00166     
00167 } // namespace faudes
00168 
00169 #endif 

libFAUDES 2.23h --- 2014.04.03 --- c++ api documentaion by doxygen