47 #ifndef _MIRA_EXCEPTION_H_ 48 #define _MIRA_EXCEPTION_H_ 78 #define MIRA_THROW(ex, msg) \ 80 std::ostringstream ex_str; \ 82 constexpr auto fileInMIRAPath = mira::chopMIRAPath(__FILE__); \ 83 throw ex(ex_str.str(), fileInMIRAPath, __LINE__).addStackInfo<ex>(); \ 92 #define MIRA_THROW_NOSTACK(ex, msg) \ 94 std::ostringstream ex_str; \ 96 constexpr auto fileInMIRAPath = mira::chopMIRAPath(__FILE__); \ 97 throw ex(ex_str.str(), fileInMIRAPath, __LINE__); \ 107 #define MIRA_THROW_EXTSTACK(ex, msg, stack, thread) \ 109 std::ostringstream ex_str; \ 111 constexpr auto fileInMIRAPath = mira::chopMIRAPath(__FILE__); \ 112 throw ex(ex_str.str(), fileInMIRAPath, __LINE__) \ 113 .addExternalStackInfo<ex>(stack, thread); \ 144 #define MIRA_RETHROW(ex, msg) \ 146 std::ostringstream ex_str; \ 148 constexpr auto fileInMIRAPath = mira::chopMIRAPath(__FILE__); \ 149 ex.addInfo(ex_str.str(),fileInMIRAPath, __LINE__); \ 166 #define MIRA_DEFINE_EXCEPTION(Ex, Base) \ 167 class Ex : public Base \ 170 Ex(std::string msg, const char* file=NULL, int line=0) MIRA_NOEXCEPT_OR_NOTHROW : \ 171 Base(std::move(msg), file, line) {} \ 173 virtual ~Ex() MIRA_NOEXCEPT_OR_NOTHROW {} \ 267 template <
typename DerivedException>
271 mStack = createCallStack();
273 return (DerivedException&)*
this;
281 template <
typename DerivedException>
284 mStack = std::move(stack);
286 return (DerivedException&)*
this;
304 Info(std::string iMessage, std::string iFile,
int iLine) :
307 std::string
what(std::size_t messageWidth)
const;
CallStack mStack
Definition: Exception.h:316
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:312
Exception(std::string message, const char *file=NULL, int line=0) MIRA_NOEXCEPT_OR_NOTHROW
The constructor.
Definition: Exception.h:209
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:230
specialize cv::DataType for our ImgPixel and inherit from cv::DataType<Vec>
Definition: IOService.h:67
Compile-time path handling.
~Exception() MIRA_NOEXCEPT_OR_NOTHROW override=default
Destructor.
std::string file
The file the exception occurred.
Definition: Exception.h:300
void addInfo(std::string message, const char *file=NULL, int line=0)
Adds additional information to the exception.
Definition: Exception.h:226
DerivedException & addStackInfo()
FOR INTERNAL USE ONLY.
Definition: Exception.h:268
uint32 ThreadID
Platform independent thread ID.
Definition: ThreadID.h:64
std::string mMessage
as cache for what()
Definition: Exception.h:318
ThreadID mThreadID
Definition: Exception.h:317
OS independent thread id.
int line
The line the exception occurred.
Definition: Exception.h:301
ThreadID getCurrentThreadID()
Get the ID of the current thread.
Definition: ThreadID.h:72
std::string message() const MIRA_NOEXCEPT_OR_NOTHROW
Similar to what().
const CallStack & callStack() const
Returns the state of the callstack at the moment when the exception was thrown.
Definition: Exception.h:253
#define MIRA_NOEXCEPT_OR_NOTHROW
Definition: NoExcept.h:99
std::list< Info > mInfos
Definition: Exception.h:315
Base class for exceptions.
Definition: Exception.h:195
The info packet that is added in MIRA_THROW and MIRA_RETHROW.
Definition: Exception.h:298
Encapsulates unix call stack functionality.
Definition: CallStack.h:75
DerivedException & addExternalStackInfo(CallStack stack, ThreadID thread)
Stores the provided callstack and thread id within the exception.
Definition: Exception.h:282
virtual const char * what() const MIRA_NOEXCEPT_OR_NOTHROW
Returns the text of exception containing the information given in MIRA_THROW and MIRA_RETHROW as well...
Exception() MIRA_NOEXCEPT_OR_NOTHROW
Definition: Exception.h:198
Info(std::string iMessage, std::string iFile, int iLine)
Definition: Exception.h:304
Compatible no-exception throwing specification.
std::string message
The exception message.
Definition: Exception.h:299
ThreadID getThreadID() const
Returns the id of the thread where the exception was thrown.
Definition: Exception.h:257
std::string what(std::size_t messageWidth) const