32 #include <casacore/casa/aips.h>
33 #include <casacore/casa/BasicSL/String.h>
35 #include <sys/types.h>
45 #define CASATHROW(exc, arg) do { \
46 std::ostringstream casa_log_oss; \
47 casa_log_oss << arg; \
48 throw exc(casa_log_oss.str()); \
55 #define AssertCc(c) ((void)0)
57 #define AssertCc(c) { if (AIPS_UNLIKELY(! (c))) {casacore::AipsError::throwIf (casacore::True, "Assertion failed: " #c, __FILE__, __LINE__, __PRETTY_FUNCTION__); }}
60 #define AssertAlways(c) { if (AIPS_UNLIKELY(! (c))) {casacore::AipsError::throwIf (casacore::True, "Assertion failed: " #c, __FILE__, __LINE__, __PRETTY_FUNCTION__); }}
64 LogIO os(LogOrigin("", __func__, __LINE__, WHERE));\
65 os << LogIO::WARN << m << LogIO::POST;\
71 #define AssertOrWarn(c,m) ((void)0)
73 #define AssertOrWarn(c,m)\
74 { if (AIPS_UNLIKELY(! (c))) {\
82 { casacore::AipsError anAipsError ((m), __FILE__, __LINE__); \
85 # define ThrowCc(m) throw casacore::AipsError ((m), __FILE__, __LINE__)
89 #define ThrowIf(c,m) {if (AIPS_UNLIKELY(c)) {casacore::AipsError::throwIf (casacore::True, (m), __FILE__, __LINE__, __PRETTY_FUNCTION__);}}
93 #define ThrowIfError(c,m) {if (AIPS_UNLIKELY(c)) {casacore::AipsError::throwIfError (casacore::True, (m), __FILE__, __LINE__, __PRETTY_FUNCTION__);}}
96 #define Rethrow(e,m) {throw casacore::AipsError::repackageAipsError ((e),(m),__FILE__,__LINE__, __PRETTY_FUNCTION__);}
146 virtual const char*
what() const noexcept
191 const
char* file,
Int line,
192 const
char* func = "");
196 const
char* file,
Int line,
197 const
char* func = "");
248 size_t size()
const {
return(Size);}
516 #ifdef AIPS_NEEDS_RETHROW
517 #ifndef CASACORE_NEEDS_RETHROW
518 #define CASACORE_NEEDS_RETHROW
522 #ifdef CASACORE_NEEDS_RETHROW
523 #define RETHROW(X) throw(X);
528 #ifndef CASACORE_NO_AUTO_TEMPLATES
529 #include <casacore/casa/Exceptions/Error.tcc>
Exception which halts execution.
AbortError(const Char *str, Category c=GENERAL)
This constructs a "AbortError" from the error message.
AbortError(const String &str, Category c=GENERAL)
~AbortError() noexcept
Destructor which does nothing.
~AipsError() noexcept
Destructor which does nothing.
static String getLastStackTrace()
AipsError::Category getCategory() const
String getStackTrace() const
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.
AipsError(Category c=GENERAL)
const String & getMesg() const
AipsError(const Char *str, Category c=GENERAL)
Creates an AipsError and initializes the error message from the parameter.
static void getLastInfo(String &message, String &stackTrace)
Get or clear the stacktrace info.
static AipsError repackageAipsError(AipsError &error, const String &message, const char *file, Int line, const char *func)
Repackage an exception.
static void throwIf(Bool condition, const String &message, const char *file, Int line, const char *func="")
Throw if the condition is true.
virtual const char * what() const noexcept
Simply returns the stored error message.
static String getLastMessage()
void setMessage(const String &msg) const
Append a message.
static void clearLastInfo()
AipsError(const String &str, Category c=GENERAL)
void addStackTrace()
Add the stack trace to the message (if USE_STACKTRACE is set).
AipsError(const String &msg, const String &filename, uInt lineNumber, Category c=GENERAL)
size_t size() const
This function returns the failed allocation size.
AllocError(const Char *str, uInt sze)
This constructor takes the error message and the failed allocation size.
~AllocError() noexcept
Destructor which does nothing.
AllocError(const String &str, uInt sze)
DuplError(const String &str, Category c=BOUNDARY)
DuplError(Category c=BOUNDARY)
Creates an DuplError and initializes the error message from the parameter.
DuplError(const Char *str, Category c=BOUNDARY)
~DuplError() noexcept
Destructor which does nothing.
Base class for all indexing errors.
~IndexError() noexcept
Destructor which does nothing.
IndexError(const Char *str, Category c=BOUNDARY)
Creates an GeneralIndexError and initializes the error message from the parameter.
IndexError(const String &str, Category c=BOUNDARY)
IndexError(Category c=BOUNDARY)
Initialization error, typically of static data shared between objects.
String: the storage and methods of handling collections of characters.
const Char * c_str() const
Get char array.
Exception for an error in a system call.
static String errorMessage(int error)
Get the message belonging to an error.
~SystemCallError() noexcept
Destructor which does nothing.
SystemCallError(const String &funcName, int error, Category c=GENERAL)
This constructs a "SystemCallError" from the system call function name and the errno.
SystemCallError(int error, const String &msg, const String &filename, uInt lineNumber, Category c=GENERAL)
Duplicate key errors where the bad key is returned.
duplError(t oI, Category c=BOUNDARY)
duplError(t oI, const String &str, Category c=BOUNDARY)
duplError(t oI, const Char *str, Category c=BOUNDARY)
This constructs a "duplError" for the offending key, and an optional character string.
~duplError() noexcept
Destructor which does nothing.
Index errors returning the bad index.
indexError(t oI, Category c=BOUNDARY)
~indexError() noexcept
Destructor which does nothing.
indexError(t oI, const String &str, Category c=BOUNDARY)
indexError(t oI, const Char *str, Category c=BOUNDARY)
This constructor takes the error message and the index which cause the error to occur.
const Double c
Fundamental physical constants (SI units):
this file contains all the compiler specific defines
bool Bool
Define the standard types used by Casacore.