29#include <casacore/casa/aips.h>
30#include <casacore/casa/BasicSL/String.h>
41#define CASATHROW(exc, arg) \
43 std::ostringstream casa_log_oss; \
44 casa_log_oss << arg; \
45 throw exc(casa_log_oss.str()); \
52#define AssertCc(c) ((void)0)
56 if (AIPS_UNLIKELY(!(c))) { \
57 casacore::AipsError::throwIf(casacore::True, "Assertion failed: " #c, __FILE__, __LINE__, \
58 __PRETTY_FUNCTION__); \
63#define AssertAlways(c) \
65 if (AIPS_UNLIKELY(!(c))) { \
66 casacore::AipsError::throwIf(casacore::True, "Assertion failed: " #c, __FILE__, __LINE__, \
67 __PRETTY_FUNCTION__); \
73 LogIO os(LogOrigin("", __func__, __LINE__, WHERE)); \
74 os << LogIO::WARN << m << LogIO::POST; \
79#define AssertOrWarn(c, m) ((void)0)
81#define AssertOrWarn(c, m) \
83 if (AIPS_UNLIKELY(!(c))) { \
92 casacore::AipsError anAipsError((m), __FILE__, __LINE__); \
96#define ThrowCc(m) throw casacore::AipsError((m), __FILE__, __LINE__)
100#define ThrowIf(c, m) \
102 if (AIPS_UNLIKELY(c)) { \
103 casacore::AipsError::throwIf(casacore::True, (m), __FILE__, __LINE__, __PRETTY_FUNCTION__); \
109#define ThrowIfError(c, m) \
111 if (AIPS_UNLIKELY(c)) { \
112 casacore::AipsError::throwIfError(casacore::True, (m), __FILE__, __LINE__, \
113 __PRETTY_FUNCTION__); \
118#define Rethrow(e, m) \
120 throw casacore::AipsError::repackageAipsError((e), (m), __FILE__, __LINE__, \
121 __PRETTY_FUNCTION__); \
175 virtual const char *
what() const noexcept {
return (
message.c_str()); }
208 Int line, const
char *func);
212 const
char *func =
"");
216 const
char *func =
"");
526#ifdef AIPS_NEEDS_RETHROW
527#ifndef CASACORE_NEEDS_RETHROW
528#define CASACORE_NEEDS_RETHROW
532#ifdef CASACORE_NEEDS_RETHROW
533#define RETHROW(X) throw(X);
538#ifndef CASACORE_NO_AUTO_TEMPLATES
539#include <casacore/casa/Exceptions/Error.tcc>
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)
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.
const String & getMesg() const
static void throwIf(Bool condition, const String &message, const char *file, Int line, const char *func="")
Throw if the condition is true.
static String getLastMessage()
void setMessage(const String &msg) const
Append a message.
static void clearLastInfo()
virtual const char * what() const noexcept
Simply returns the stored error message.
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.
~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.
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.
int error() const
Get the errno.
SystemCallError(int error, const std::string &msg, const std::string &filename, uInt lineNumber, Category c=GENERAL)
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.
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.
For temporary backward namespace compatibility, use casa as alias for casacore.
bool Bool
Define the standard types used by Casacore.