30#include <casacore/casa/aips.h>
31#include <casacore/casa/BasicSL/String.h>
43#define CASATHROW(exc, arg) do { \
44 std::ostringstream casa_log_oss; \
45 casa_log_oss << arg; \
46 throw exc(casa_log_oss.str()); \
53#define AssertCc(c) ((void)0)
55#define AssertCc(c) { if (AIPS_UNLIKELY(! (c))) {casacore::AipsError::throwIf (casacore::True, "Assertion failed: " #c, __FILE__, __LINE__, __PRETTY_FUNCTION__); }}
58#define AssertAlways(c) { if (AIPS_UNLIKELY(! (c))) {casacore::AipsError::throwIf (casacore::True, "Assertion failed: " #c, __FILE__, __LINE__, __PRETTY_FUNCTION__); }}
62 LogIO os(LogOrigin("", __func__, __LINE__, WHERE));\
63 os << LogIO::WARN << m << LogIO::POST;\
69#define AssertOrWarn(c,m) ((void)0)
71#define AssertOrWarn(c,m)\
72{ if (AIPS_UNLIKELY(! (c))) {\
80 { casacore::AipsError anAipsError ((m), __FILE__, __LINE__); \
83# define ThrowCc(m) throw casacore::AipsError ((m), __FILE__, __LINE__)
87#define ThrowIf(c,m) {if (AIPS_UNLIKELY(c)) {casacore::AipsError::throwIf (casacore::True, (m), __FILE__, __LINE__, __PRETTY_FUNCTION__);}}
91#define ThrowIfError(c,m) {if (AIPS_UNLIKELY(c)) {casacore::AipsError::throwIfError (casacore::True, (m), __FILE__, __LINE__, __PRETTY_FUNCTION__);}}
94#define Rethrow(e,m) {throw casacore::AipsError::repackageAipsError ((e),(m),__FILE__,__LINE__, __PRETTY_FUNCTION__);}
144 virtual const char*
what() const noexcept
189 const
char* file,
Int line,
190 const
char* func = "");
194 const
char* file,
Int line,
195 const
char* func = "");
246 size_t size()
const {
return(Size);}
514#ifdef AIPS_NEEDS_RETHROW
515#ifndef CASACORE_NEEDS_RETHROW
516#define CASACORE_NEEDS_RETHROW
520#ifdef CASACORE_NEEDS_RETHROW
521#define RETHROW(X) throw(X);
526#ifndef CASACORE_NO_AUTO_TEMPLATES
527#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)
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.
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.
this file contains all the compiler specific defines
bool Bool
Define the standard types used by Casacore.