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_DEBUG(fmt, ...) \
78  do { \
79  double now = crl::multisense::details::utility::TimeStamp::getCurrentTime(); \
80  CRL_DEBUG_REDIRECTION "[%.3f] %s(%d): %s: " fmt,now,CRL_FILENAME,__LINE__, \
81  CRL_PRETTY_FUNCTION,##__VA_ARGS__); \
82  } while(0)
83 
84 
85 namespace crl {
86 namespace multisense {
87 namespace details {
88 namespace utility {
89 
90 class Exception : public std::exception
91 {
92 private:
93 
94  std::string reason;
95 
96 public:
97 
98  Exception(const char *failureReason, ...);
99  Exception(const std::string& failureReason);
100  ~Exception() throw();
101 
102  virtual const char* what() const throw();
103 };
104 
105 }}}} // namespaces
106 
107 #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 Sat Apr 6 2019 02:16:46