/usr/include/mathic/error.h is in libmathic-dev 1.0~git20160320-4.
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 | #ifndef MATHIC_ERROR_GUARD
#define MATHIC_ERROR_GUARD
#include <stdexcept>
#include <string>
namespace mathic {
/** This is the base of the Mathic exception hierarchy for exceptions
that can occur due to expected error conditions. */
class MathicException : public std::runtime_error {
public:
MathicException(const std::string& str): runtime_error(str) {}
};
/** This exception signals that a bug in Mathic has been detected. */
class InternalMathicException : public std::logic_error {
public:
InternalMathicException(const std::string& str): logic_error(str) {}
};
// The do {...} while (0) is to collect everything into a single
// statement that still requires a semicolon after it. The throw is to
// prevent spurious compiler warnings about a missing return
// statement.
#define MATHIC_INTERNAL_ERROR(msg) \
do { \
reportInternalError(msg, __FILE__, __LINE__); \
throw; \
} while (false)
#define INTERNAL_ERROR_UNIMPLEMENTED() \
INTERNAL_ERROR("Called function that has not been implemented.")
// These methods throw exceptions.
void reportError(const std::string& errorMsg);
void reportInternalError(const std::string& errorMsg);
void reportInternalError
(const std::string& errorMsg, const char* file, unsigned int lineNumber);
template<class Exception>
void throwError(const std::string& errorMsg) {
throw Exception("ERROR: " + errorMsg + '\n');
}
#define MATHIC_DEFINE_EXCEPTION(NAME) \
class NAME##Exception : public MathicException { \
public: \
NAME##Exception(const std::string& str): MathicException(str) {} \
}
MATHIC_DEFINE_EXCEPTION(UnknownName);
MATHIC_DEFINE_EXCEPTION(AmbiguousName);
MATHIC_DEFINE_EXCEPTION(Unsupported);
}
#endif
|