1 // Project MULTIPR, IOLS WP1.2.1 - EDF/CS
2 // Partitioning/decimation module for the SALOME v3.2 platform
5 * \file MULTIPR_Exceptions.hxx
7 * \brief All the exceptions used by MULTIPR.
9 * \author Olivier LE ROUX - CS, Virtual Reality Dpt
14 #ifndef MULTIPR_EXCEPTIONS_HXX
15 #define MULTIPR_EXCEPTIONS_HXX
17 //*****************************************************************************
19 //*****************************************************************************
28 //*****************************************************************************
29 // Class RuntimeException
30 // Super class for all exceptions used by the module MULTIPR
31 //*****************************************************************************
33 class RuntimeException
38 * Constructor. Build a new RuntimeException.
39 * \param pMsg message to be associated with this exception.
40 * \param pFile name of the file where the probem occur (you can use the macro __FILE__); "unknown" by default.
41 * \param pLine number of the line where the probem occur (you can use the macro __LINE__); 0 by default.
44 const std::string& pMsg,
45 const std::string& pFile = "unknown",
51 mType = "RuntimeException";
55 * Dumps info about this exception to the given output stream.
57 void dump(std::ostream& pOs) const
59 pOs << "MULTIPR: " << mType << " (" << mFile << ", line " << mLine << "): " << mMsg << std::endl;
64 std::string mMsg; /**< Message associated with this exception. */
65 std::string mFile; /**< Name of the source file where the problem occurs. */
66 int mLine; /**< Number of the line where the problem occurs. */
67 std::string mType; /**< Type of this exception. */
71 //*****************************************************************************
72 // Class NullArgumentException
73 // Should be used for a NULL pointer
74 //*****************************************************************************
76 class NullArgumentException : public RuntimeException
79 NullArgumentException(
80 const std::string& pMsg,
81 const std::string& pFile="unknown",
82 int pLine=0) : RuntimeException(pMsg, pFile, pLine)
84 mType = "NullArgumentException";
89 //*****************************************************************************
90 // Class IllegalArgumentException
91 // Should be used when a parameter is invalid (check precondition)
92 //*****************************************************************************
94 class IllegalArgumentException : public RuntimeException
97 IllegalArgumentException(
98 const std::string& pMsg,
99 const std::string& pFile="unknown",
100 int pLine=0) : RuntimeException(pMsg, pFile, pLine)
102 mType = "IllegalArgumentException";
107 //*****************************************************************************
108 // Class IllegalStateException
109 // Should be used when the internal state of an object is invalid
110 //*****************************************************************************
112 class IllegalStateException : public RuntimeException
115 IllegalStateException(
116 const std::string& pMsg,
117 const std::string& pFile="unknown",
118 int pLine=0) : RuntimeException(pMsg, pFile, pLine)
120 mType = "IllegalStateException";
125 //*****************************************************************************
126 // Class IndexOutOfBoundsException
127 // Should be used when an index is out of bounds
128 //*****************************************************************************
130 class IndexOutOfBoundsException : public RuntimeException
133 IndexOutOfBoundsException(
134 const std::string& pMsg,
135 const std::string& pFile="unknown",
136 int pLine=0) : RuntimeException(pMsg, pFile, pLine)
138 mType = "IndexOutOfBoundsException";
143 //*****************************************************************************
145 // Should be used when any i/o error occurs
146 //*****************************************************************************
148 class IOException : public RuntimeException
152 const std::string& pMsg,
153 const std::string& pFile="unknown",
154 int pLine=0) : RuntimeException(pMsg, pFile, pLine)
156 mType = "IOException";
161 //*****************************************************************************
162 // Class FileNotFoundException
163 // Should be used to indicate that a file has not been found
164 //*****************************************************************************
166 class FileNotFoundException : public IOException
169 FileNotFoundException(
170 const std::string& pMsg,
171 const std::string& pFile="unknown",
172 int pLine=0) : IOException(pMsg, pFile, pLine)
174 mType = "FileNotFoundException";
179 //*****************************************************************************
180 // Class UnsupportedOperationException
181 // Should be used when a function/method is not yet implemented or
182 // if an operation is not supported in a given context
183 //*****************************************************************************
185 class UnsupportedOperationException : public RuntimeException
188 UnsupportedOperationException(
189 const std::string& pMsg,
190 const std::string& pFile="unknown",
191 int pLine=0) : RuntimeException(pMsg, pFile, pLine)
193 mType = "UnsupportedOperationException";
198 } // namespace MULTIPR
201 #endif // MULTIPR_EXCEPTIONS_HXX