00001
00002
00003
00004
00005
00006
00007
00008
00010
00011
00012 #ifndef __LIDAR_ERROR_H__
00013 #define __LIDAR_ERROR_H__
00014
00015 #include "lidar/Base.h"
00016 #include <exception>
00017
00018 LT_BEGIN_LIDAR_NAMESPACE
00019
00021 #define THROW_LIBRARY_ERROR(code) \
00022 throw Error(__FILE__, __FUNCTION__, __LINE__, code)
00023
00025 #define THROW_OS_ERROR() \
00026 throw OSError(__FILE__, __FUNCTION__, __LINE__)
00027
00031 class Error : public std::exception
00032 {
00033 public:
00034 ~Error(void) throw();
00035 Error(const Error ©) throw();
00036
00046 Error(const char *file, const char *func, int line, int code) throw();
00047
00053 const char *filename(void) const throw();
00059 const char *function(void) const throw();
00065 int line(void) const throw();
00071 int error(void) const throw();
00072
00078 const char *what(void) const throw();
00079
00087 Error &operator()(const char *fmt, ...) throw();
00088
00089 protected:
00090 enum { BUFFERSIZE = 1024 };
00091 char m_desc[BUFFERSIZE];
00092 const char *m_file;
00093 const char *m_func;
00094 int m_line;
00095 int m_error;
00096 };
00097
00102 class OSError : public Error
00103 {
00104 public:
00116 OSError(const char *file, const char *func, int line) throw();
00117 };
00118
00119 LT_END_LIDAR_NAMESPACE
00120 #endif // __LIDAR_ERROR_H__