32 #include <casacore/casa/aips.h> 33 #include <casacore/casa/BasicSL/String.h> 34 #include <casacore/casa/OS/Mutex.h> 36 #include <sys/types.h> 46 #define CASATHROW(exc, arg) do { \ 47 std::ostringstream casa_log_oss; \ 48 casa_log_oss << arg; \ 49 throw exc(casa_log_oss.str()); \ 56 #define AssertCc(c) {assert (c); } 58 #define AssertCc(c) { if (! (c)) {casacore::AipsError::throwIf (casacore::True, "Assertion failed: " #c, __FILE__, __LINE__, __PRETTY_FUNCTION__); }} 61 #define AssertAlways(c) { if (! (c)) {casacore::AipsError::throwIf (casacore::True, "Assertion failed: " #c, __FILE__, __LINE__, __PRETTY_FUNCTION__); }} 65 LogIO os(LogOrigin("", __func__, __LINE__, WHERE));\ 66 os << LogIO::WARN << m << LogIO::POST;\ 72 #define AssertOrWarn(c,m) {assert (c);} 74 #define AssertOrWarn(c,m)\ 83 { casacore::AipsError anAipsError ((m), __FILE__, __LINE__); \ 86 # define ThrowCc(m) throw casacore::AipsError ((m), __FILE__, __LINE__) 90 #define ThrowIf(c,m) {if (c) {casacore::AipsError::throwIf (casacore::True, (m), __FILE__, __LINE__, __PRETTY_FUNCTION__);}} 94 #define ThrowIfError(c,m) {if (c) {casacore::AipsError::throwIfError (casacore::True, (m), __FILE__, __LINE__, __PRETTY_FUNCTION__);}} 97 #define Rethrow(e,m) {throw casacore::AipsError::repackageAipsError ((e),(m),__FILE__,__LINE__, __PRETTY_FUNCTION__);} 147 virtual const char*
what()
const throw()
192 const char* file,
Int line,
193 const char* func =
"");
197 const char* file,
Int line,
198 const char* func =
"");
249 size_t size()
const {
return(Size);}
453 static String errorMessage(
int error);
500 #ifdef AIPS_NEEDS_RETHROW 501 #ifndef CASACORE_NEEDS_RETHROW 502 #define CASACORE_NEEDS_RETHROW 506 #ifdef CASACORE_NEEDS_RETHROW 507 #define RETHROW(X) throw(X); 512 #ifndef CASACORE_NO_AUTO_TEMPLATES 513 #include <casacore/casa/Exceptions/Error.tcc> 514 #endif //# CASACORE_NO_AUTO_TEMPLATES
AipsError::Category getCategory() const
DuplError(const String &str, Category c=BOUNDARY)
~AipsError()
Destructor which does nothing.
AipsError(const Char *str, Category c=GENERAL)
Creates an AipsError and initializes the error message from the parameter.
const String & getMesg() const
DuplError(const Char *str, Category c=BOUNDARY)
static void throwIf(Bool condition, const String &message, const char *file, Int line, const char *func="")
Throw if the condition is true.
DuplError(Category c=BOUNDARY)
Creates an DuplError and initializes the error message from the parameter.
IndexError(Category c=BOUNDARY)
const Char * c_str() const
Get char array.
AllocError(const Char *str, uInt sze)
This constructor takes the error message and the failed allocation size.
indexError(t oI, Category c=BOUNDARY)
Index errors returning the bad index.
String getStackTrace() const
size_t size() const
This function returns the failed allocation size.
AllocError(const String &str, uInt sze)
static String getLastMessage()
int error() const
Get the errno.
static void throwIfError(Int errorCode, const String &prefix, const char *file, Int line, const char *func="")
Throw if the system error code is not 0.
static void getLastInfo(String &message, String &stackTrace)
Get or clear the stacktrace info.
duplError(t oI, Category c=BOUNDARY)
IndexError(const Char *str, Category c=BOUNDARY)
Creates an GeneralIndexError and initializes the error message from the parameter.
Base class for all indexing errors.
void addStackTrace()
Add the stack trace to the message (if USE_STACKTRACE is set).
virtual const char * what() const
Simply returns the stored error message.
bool Bool
Define the standard types used by Casacore.
static String getLastStackTrace()
Exception which halts execution.
IndexError(const String &str, Category c=BOUNDARY)
Base class for all Casacore library errors.
static void clearLastInfo()
const Double c
Fundamental physical constants (SI units):
void setMessage(const String &msg) const
Append a message.
String: the storage and methods of handling collections of characters.
Duplicate key errors where the bad key is returned.
static AipsError repackageAipsError(AipsError &error, const String &message, const char *file, Int line, const char *func)
Repackage an exception.
Exception for an error in a system call.
this file contains all the compiler specific defines