/usr/include/XdmfError.hpp is in libxdmf-dev 3.0+git20160803-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 | #ifndef XDMFERROR_HPP_
#define XDMFERROR_HPP_
// C Compatible Includes
#include "XdmfCore.hpp"
#ifdef __cplusplus
// Includes
#include <iosfwd>
#include <sstream>
#include <exception>
class XDMFCORE_EXPORT XdmfError : public std::exception
{
public:
enum Level {FATAL, WARNING, DEBUG};
/**
* One of the constructors for XdmfError, this one doesn't print to the buffer.
*
* Example of use:
*
* C++
*
* @dontinclude ExampleXdmfError.cpp
* @skipline //#initialization
* @until //#initialization
*
* Python:
*
* @dontinclude XdmfExampleError.py
* @skipline #//initialization
* @until #//initialization
*
* @param level The error level of the exception being constructed
* @param message The message to be attached to the exception
*/
XdmfError(Level level, std::string message);
~XdmfError() throw();
/**
* Sets the error level of the exception.
*
* Example of use:
*
* C++
*
* @dontinclude ExampleXdmfError.cpp
* @skipline //#initialization
* @until //#initialization
* @skipline //#setLevel
* @until //#setLevel
*
* Python:
*
* @dontinclude XdmfExampleError.py
* @skipline #//setLevel
* @until #//setLevel
*
* @param l The new level of the exception
*/
void setLevel(Level l);
/**
* Gets the error level of the exception.
*
* Example of use:
*
* C++
*
* @dontinclude ExampleXdmfError.cpp
* @skipline //#initialization
* @until //#initialization
* @skipline //#getLevel
* @until //#getLevel
*
* Python:
*
* @dontinclude XdmfExampleError.py
* @skipline #//getLevel
* @until #//getLevel
*
* @return The error level of the exception
*/
Level getLevel() const;
/**
* Gets whether C errors are Fatal. If set to false a status will be returned
* to C when an error is thrown. Otherwise there will be no handling and the
* program will exit since C cannot handle exceptions.
*
* @param status Whether the C wrappers are to pass an integer value to
* C on failure instead of exiting.
*/
static void setCErrorsAreFatal(bool status);
/**
* Sets the level limit for Errors. This determines what level of errors will be thrown with message.
*
* Example of use:
*
* C++
*
* @dontinclude ExampleXdmfError.cpp
* @skipline //#initialization
* @until //#initialization
* @skipline //#setLevelLimit
* @until //#setLevelLimit
*
* Python
*
* @dontinclude XdmfExampleError.py
* @skipline #//setLevelLimit
* @until #//setLevelLimit
*
* @param l The cutoff level for sending exceptions via message
*/
static void setLevelLimit(Level l);
/**
* Sets the minimum Error level that displays messages with the message function.
*
* Example of use:
*
* C++
*
* @dontinclude ExampleXdmfError.cpp
* @skipline //#setSuppressionLevel
* @until //#setSuppressionLevel
*
* Python
*
* @dontinclude XdmfExampleError.py
* @skipline #//setSuppressionLevel
* @until #//setSuppressionLevel
*
* @param l The new minimum error level to display a message
*/
static void setSuppressionLevel(Level l);
/**
* Gets whether C errors are Fatal. If set to false a status will be returned
* to C when an error is thrown. Otherwise there will be no handling and the
* program will exit since C cannot handle exceptions.
*
* @return Whether the C wrappers with pass an integer value to C
* instead of stopping the program
*/
static bool getCErrorsAreFatal();
/**
* Gets the level limit for Errors.
*
* Example of use:
*
* C++
*
* @dontinclude ExampleXdmfError.cpp
* @skipline //#initialization
* @until //#initialization
* @skipline //#getLevelLimit
* @until //#getLevelLimit
*
* Python
*
* @dontinclude XdmfExampleError.py
* @skipline #//getLevelLimit
* @until #//getLevelLimit
*
* @return The cuttof level for sending exceptions via message
*/
static Level getLevelLimit();
/**
* Gets the minimum Error level that displays messages with the message function.
*
* @dontinclude ExampleXdmfError.cpp
* @skipline //#getSuppressionLevel
* @until //#getSuppressionLevel
*
* Python
*
* @dontinclude XdmfExampleError.py
* @skipline #//getSuppressionLevel
* @until #//getSuppressionLevel
*
* @return The minimum error level to display a message
*/
static Level getSuppressionLevel();
/**
* Alternate constructor for XdmfError exceptions.
* This one automatically prints out the message provided if the error level
* above the suppression level. If the error level is not above the
* level limit an exception will not be thrown.
*
* Example of use:
*
* C++
*
* @dontinclude ExampleXdmfError.cpp
* @skipline //#initialization
* @until //#initialization
* @skipline //#message
* @until //#message
*
* Python: Generates a RuntimeError instead of an XdmfError in Python
*
* @dontinclude XdmfExampleError.py
* @skipline #//message
* @until #//message
*
* @param l The level of the error to be generated
* @param msg The message to be associated with the error generated and printed out
*/
static void message(Level l, std::string msg);
/**
* Sets which buffer the error messages are printed to with the message function.
*
* Example of use:
*
* C++
*
* @dontinclude ExampleXdmfError.cpp
* @skipline //#initialization
* @until //#initialization
* @skipline //#setBuffer
* @until //#setBuffer
*
* Python: Not supported in Python
*
* @param buf The buffer that the error messages will be printed to
*/
static void setBuffer(std::streambuf* buf);
/**
* Gets the message associated with this exception.
*
* Example of use:
*
* C++
*
* @dontinclude ExampleXdmfError.cpp
* @skipline //#initialization
* @until //#initialization
* @skipline //#what
* @until //#what
*
* Python
*
* @dontinclude XdmfExampleError.py
* @skipline #//what
* @until #//what
*
* @return The message associated with the exception
*/
virtual const char * what() const throw();
private:
Level mLevel;
static Level mLevelLimit;
static Level mSuppressLevel;
static std::streambuf* mBuf;
static bool mCErrorsAreFatal;
std::string mMessage;
static void WriteToStream(std::string msg);
};
#endif
#ifdef __cplusplus
extern "C" {
#endif
// C wrappers go here
#define XDMF_SUCCESS 1
#define XDMF_FAIL -1
#define XDMF_ERROR_FATAL 40
#define XDMF_ERROR_WARNING 41
#define XDMF_ERROR_DEBUG 42
XDMFCORE_EXPORT void XdmfErrorSetCErrorsAreFatal(int status);
XDMFCORE_EXPORT void XdmfErrorSetLevelLimit(int level, int * status);
XDMFCORE_EXPORT void XdmfErrorSetSuppressionLevel(int level, int * status);
XDMFCORE_EXPORT int XdmfErrorGetCErrorsAreFatal();
XDMFCORE_EXPORT int XdmfErrorGetLevelLimit();
XDMFCORE_EXPORT int XdmfErrorGetSuppressionLevel();
#ifdef __cplusplus
//Use these macros to catch Exceptions for C code
#define XDMF_ERROR_WRAP_START(status) \
if (status) { \
*status = XDMF_SUCCESS; \
} \
try {
#define XDMF_ERROR_WRAP_END(status) \
} \
catch (XdmfError & e) { \
if (XdmfError::getCErrorsAreFatal()) { \
throw e; \
} \
else { \
if (status) { \
*status = XDMF_FAIL; \
} \
} \
}
}
#endif
#endif
|