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 {} \ 272 template <
typename DerivedException>
276 mStack = createCallStack();
278 return (DerivedException&)*
this;
286 template <
typename DerivedException>
289 mStack = std::move(stack);
291 return (DerivedException&)*
this;
309 Info(std::string iMessage, std::string iFile,
int iLine) :
312 std::string
what(std::size_t messageWidth)
const;
CallStack mStack
Definition: Exception.h:321
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:317
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:233
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:305
void addInfo(std::string message, const char *file=NULL, int line=0)
Adds additional information to the exception.
Definition: Exception.h:231
DerivedException & addStackInfo()
FOR INTERNAL USE ONLY.
Definition: Exception.h:273
uint32 ThreadID
Platform independent thread ID.
Definition: ThreadID.h:64
std::string mMessage
as cache for what()
Definition: Exception.h:323
ThreadID mThreadID
Definition: Exception.h:322
OS independent thread id.
int line
The line the exception occurred.
Definition: Exception.h:306
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:258
#define MIRA_NOEXCEPT_OR_NOTHROW
Definition: NoExcept.h:99
std::list< Info > mInfos
Definition: Exception.h:320
Base class for exceptions.
Definition: Exception.h:195
The info packet that is added in MIRA_THROW and MIRA_RETHROW.
Definition: Exception.h:303
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:287
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:309
Exception & operator=(const Exception &)=default
Compatible no-exception throwing specification.
std::string message
The exception message.
Definition: Exception.h:304
ThreadID getThreadID() const
Returns the id of the thread where the exception was thrown.
Definition: Exception.h:262
std::string what(std::size_t messageWidth) const