Exception.hh
Go to the documentation of this file.
1 
41 #ifndef CRL_MULTISENSE_EXCEPTION_HH
42 #define CRL_MULTISENSE_EXCEPTION_HH
43 
44 #include <stdio.h>
45 #include <string.h>
46 #include <exception>
47 #include <string>
48 
49 #include "TimeStamp.hh"
50 #include "Portability.hh"
51 
52 #ifdef CRL_DEBUG_SYSLOG
53 #include <syslog.h>
54 #define CRL_DEBUG_REDIRECTION syslog(LOG_USER|LOG_INFO,
55 #else
56 #define CRL_DEBUG_REDIRECTION fprintf(stderr,
57 #endif // CRL_DEBUG_SYSLOG
58 
59 #ifdef WIN32
60 #define CRL_FILENAME \
61  (strrchr(__FILE__,'\\') \
62  ? strrchr(__FILE__,'\\')+1 \
63  : __FILE__)
64 #else
65 #define CRL_FILENAME \
66  (strrchr(__FILE__,'/') \
67  ? strrchr(__FILE__,'/')+1 \
68  : __FILE__)
69 #endif
70 
71 #define CRL_EXCEPTION(fmt, ...) \
72  do { \
73  throw crl::multisense::details::utility::Exception("%s(%d): %s: " fmt,CRL_FILENAME,__LINE__, \
74  CRL_PRETTY_FUNCTION,##__VA_ARGS__); \
75  } while(0)
76 
77 #define CRL_EXCEPTION_RAW(fmt) \
78  do { \
79  throw crl::multisense::details::utility::Exception("%s(%d): %s: " fmt,CRL_FILENAME,__LINE__, \
80  CRL_PRETTY_FUNCTION); \
81  } while(0)
82 
83 #define CRL_DEBUG(fmt, ...) \
84  do { \
85  double now = crl::multisense::details::utility::TimeStamp::getCurrentTime(); \
86  CRL_DEBUG_REDIRECTION "[%.3f] %s(%d): %s: " fmt,now,CRL_FILENAME,__LINE__, \
87  CRL_PRETTY_FUNCTION,##__VA_ARGS__); \
88  } while(0)
89 
90 #define CRL_DEBUG_RAW(fmt) \
91  do { \
92  double now = crl::multisense::details::utility::TimeStamp::getCurrentTime(); \
93  CRL_DEBUG_REDIRECTION "[%.3f] %s(%d): %s: " fmt,now,CRL_FILENAME,__LINE__, \
94  CRL_PRETTY_FUNCTION); \
95  } while(0)
96 
97 namespace crl {
98 namespace multisense {
99 namespace details {
100 namespace utility {
101 
102 class Exception : public std::exception
103 {
104 private:
105 
106  std::string reason;
107 
108 public:
109 
110  Exception(const char *failureReason, ...);
111  Exception(const std::string& failureReason);
112  ~Exception() throw();
113 
114  virtual const char* what() const throw();
115 };
116 
117 }}}} // namespaces
118 
119 #endif /* #ifndef CRL_MULTISENSE_EXCEPTION_HH */
Definition: channel.cc:56
Exception(const char *failureReason,...)
Definition: Exception.cc:88
virtual const char * what() const
Definition: Exception.cc:120


multisense_lib
Author(s):
autogenerated on Sun Mar 14 2021 02:34:50