47 #ifndef _MIRA_EXCEPTION_H_ 48 #define _MIRA_EXCEPTION_H_ 81 #define MIRA_THROW(ex, msg) \ 83 std::ostringstream ex_str; \ 85 throw ex(ex_str.str(), __FILE__, __LINE__).addStackInfo<ex>(); \ 94 #define MIRA_THROW_NOSTACK(ex, msg) \ 96 std::ostringstream ex_str; \ 98 throw ex(ex_str.str(), __FILE__, __LINE__) \ 108 #define MIRA_THROW_EXTSTACK(ex, msg, stack, thread) \ 110 std::ostringstream ex_str; \ 112 throw ex(ex_str.str(), __FILE__, __LINE__) \ 113 .addExternalStackInfo<ex>(stack, thread); \ 144 #define MIRA_RETHROW(ex, msg) \ 146 std::ostringstream ex_str; \ 148 ex.addInfo(ex_str.str(),__FILE__, __LINE__); \ 165 #define MIRA_DEFINE_EXCEPTION(Ex, Base) \ 166 class Ex : public Base \ 169 Ex(const std::string& msg, const char* file=NULL, int line=0) MIRA_NOEXCEPT_OR_NOTHROW : \ 170 Base(msg, file, line) {} \ 172 virtual ~Ex() MIRA_NOEXCEPT_OR_NOTHROW {} \ 210 addInfo(message,
file, line);
225 void addInfo(
const std::string& message,
const char*
file=NULL,
int line=0)
227 mInfos.push_back(
Info(message,
file ? std::string(
file) :
"", line));
266 template <
typename DerivedException>
270 mStack = getCallStack();
271 mThreadID = getCurrentThreadID();
272 return (DerivedException&)*
this;
280 template <
typename DerivedException>
285 return (DerivedException&)*
this;
303 Info(
const std::string& iMessage,
const std::string& iFile,
int iLine) :
304 message(iMessage),
file(iFile), line(iLine) {}
306 std::string what(std::size_t messageWidth)
const;
311 const Info&
getInfo()
const { assert(!mInfos.empty());
return mInfos.front(); }
CallStack mStack
Definition: Exception.h:315
Encapsulates call stack functionality.
const Info & getInfo() const
Returns the first info packet that describes the location where the exception has occured...
Definition: Exception.h:311
PropertyHint file(const std::string &filters=std::string(), bool save=false)
Tells the property editor that the path is for a file, and that it should show a "File Open"/"File Sa...
Definition: Path.h:247
specialize cv::DataType for our ImgPixel and inherit from cv::DataType<Vec>
Definition: IOService.h:67
Info(const std::string &iMessage, const std::string &iFile, int iLine)
Definition: Exception.h:303
std::string file
The file the exception occurred.
Definition: Exception.h:299
DerivedException & addStackInfo()
FOR INTERNAL USE ONLY.
Definition: Exception.h:267
uint32 ThreadID
Platform independent thread ID.
Definition: ThreadID.h:68
std::string mMessage
as cache for what()
Definition: Exception.h:317
ThreadID mThreadID
Definition: Exception.h:316
OS independent thread id.
int line
The line the exception occurred.
Definition: Exception.h:300
#define MIRA_NOEXCEPT_OR_NOTHROW
Definition: NoExcept.h:99
std::list< Info > mInfos
Definition: Exception.h:314
Base class for exceptions.
Definition: Exception.h:194
Exception(const std::string &message, const char *file=NULL, int line=0) MIRA_NOEXCEPT_OR_NOTHROW
The constructor.
Definition: Exception.h:208
The info packet that is added in MIRA_THROW and MIRA_RETHROW.
Definition: Exception.h:297
Encapsulates unix call stack functionality.
Definition: CallStack.h:86
Exception() MIRA_NOEXCEPT_OR_NOTHROW
Definition: Exception.h:197
void addInfo(const std::string &message, const char *file=NULL, int line=0)
Adds additional information to the exception.
Definition: Exception.h:225
virtual ~Exception() MIRA_NOEXCEPT_OR_NOTHROW
Destructor.
Definition: Exception.h:214
DerivedException & addExternalStackInfo(const CallStack &stack, ThreadID thread)
Stores the provided callstack and thread id within the exception.
Definition: Exception.h:281
Compatible no-exception throwing specification.
std::string message
The exception message.
Definition: Exception.h:298
ThreadID getThreadID() const
Returns the id of the thread where the exception was thrown.
Definition: Exception.h:256