Exception.hh
Go to the documentation of this file.
00001 
00041 #ifndef CRL_MULTISENSE_EXCEPTION_HH
00042 #define CRL_MULTISENSE_EXCEPTION_HH
00043 
00044 #include <stdio.h>
00045 #include <string.h>
00046 #include <exception>
00047 #include <string>
00048 
00049 #include "TimeStamp.hh"
00050 #include "Portability.hh"
00051 
00052 #ifdef CRL_DEBUG_SYSLOG
00053 #include <syslog.h>
00054 #define CRL_DEBUG_REDIRECTION syslog(LOG_USER|LOG_INFO,
00055 #else
00056 #define CRL_DEBUG_REDIRECTION fprintf(stderr,
00057 #endif // CRL_DEBUG_SYSLOG
00058 
00059 #ifdef WIN32
00060 #define CRL_FILENAME                            \
00061         (strrchr(__FILE__,'\\')                     \
00062          ? strrchr(__FILE__,'\\')+1                 \
00063          : __FILE__)
00064 #else
00065 #define CRL_FILENAME                            \
00066     (strrchr(__FILE__,'/')                      \
00067      ? strrchr(__FILE__,'/')+1                  \
00068      : __FILE__)
00069 #endif
00070 
00071 #define CRL_EXCEPTION(fmt, ...)                                         \
00072     do {                                                                \
00073         throw crl::multisense::details::utility::Exception("%s(%d): %s: " fmt,CRL_FILENAME,__LINE__, \
00074                                                            CRL_PRETTY_FUNCTION,##__VA_ARGS__); \
00075     } while(0)
00076 
00077 #define CRL_DEBUG(fmt, ...)                                             \
00078     do {                                                                \
00079         double now = crl::multisense::details::utility::TimeStamp::getCurrentTime(); \
00080         CRL_DEBUG_REDIRECTION "[%.3f] %s(%d): %s: " fmt,now,CRL_FILENAME,__LINE__, \
00081                 CRL_PRETTY_FUNCTION,##__VA_ARGS__);                     \
00082     } while(0)
00083 
00084 
00085 namespace crl {
00086 namespace multisense {
00087 namespace details {
00088 namespace utility {
00089 
00090 class Exception : public std::exception
00091 {
00092 private:
00093 
00094     std::string reason;
00095 
00096 public:
00097 
00098     Exception(const char *failureReason, ...);
00099     Exception(const std::string& failureReason);
00100     ~Exception() throw();
00101 
00102     virtual const char* what() const throw();
00103 };
00104 
00105 }}}} // namespaces
00106 
00107 #endif /* #ifndef CRL_MULTISENSE_EXCEPTION_HH */


multisense_lib
Author(s):
autogenerated on Fri Apr 5 2019 02:28:24