00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #ifndef PCL_EXCEPTIONS_H_
00038 #define PCL_EXCEPTIONS_H_
00039
00040 #include <stdexcept>
00041 #include <sstream>
00042 #include <pcl/pcl_macros.h>
00043 #include <boost/current_function.hpp>
00044
00050 #define PCL_THROW_EXCEPTION(ExceptionName, message) \
00051 { \
00052 std::ostringstream s; \
00053 s << message; \
00054 s.flush (); \
00055 throw ExceptionName(s.str(), __FILE__, BOOST_CURRENT_FUNCTION, __LINE__); \
00056 }
00057
00058 namespace pcl
00059 {
00060
00065 class PCLException : public std::runtime_error
00066 {
00067 public:
00068
00069 PCLException (const std::string& error_description,
00070 const std::string& file_name = "",
00071 const std::string& function_name = "" ,
00072 unsigned line_number = 0) throw ()
00073 : std::runtime_error (error_description)
00074 , file_name_ (file_name)
00075 , function_name_ (function_name)
00076 , message_ (error_description)
00077 , line_number_ (line_number)
00078 {
00079 message_ = detailedMessage ();
00080 }
00081
00082 virtual ~PCLException () throw ()
00083 {}
00084
00085 const std::string&
00086 getFileName () const throw ()
00087 {
00088 return (file_name_);
00089 }
00090
00091 const std::string&
00092 getFunctionName () const throw ()
00093 {
00094 return (function_name_);
00095 }
00096
00097 unsigned
00098 getLineNumber () const throw ()
00099 {
00100 return (line_number_);
00101 }
00102
00103 std::string
00104 detailedMessage () const throw ()
00105 {
00106 std::stringstream sstream;
00107 if (function_name_ != "")
00108 sstream << function_name_ << " ";
00109
00110 if (file_name_ != "")
00111 {
00112 sstream << "in " << file_name_ << " ";
00113 if (line_number_ != 0)
00114 sstream << "@ " << line_number_ << " ";
00115 }
00116 sstream << ": " << what ();
00117
00118 return (sstream.str ());
00119 }
00120
00121 char const*
00122 what () const throw ()
00123 {
00124 return (message_.c_str ());
00125 }
00126
00127 protected:
00128 std::string file_name_;
00129 std::string function_name_;
00130 std::string message_;
00131 unsigned line_number_;
00132 } ;
00133
00137 class InvalidConversionException : public PCLException
00138 {
00139 public:
00140
00141 InvalidConversionException (const std::string& error_description,
00142 const std::string& file_name = "",
00143 const std::string& function_name = "" ,
00144 unsigned line_number = 0) throw ()
00145 : pcl::PCLException (error_description, file_name, function_name, line_number) { }
00146 } ;
00147
00151 class IsNotDenseException : public PCLException
00152 {
00153 public:
00154
00155 IsNotDenseException (const std::string& error_description,
00156 const std::string& file_name = "",
00157 const std::string& function_name = "" ,
00158 unsigned line_number = 0) throw ()
00159 : pcl::PCLException (error_description, file_name, function_name, line_number) { }
00160 } ;
00161
00166 class InvalidSACModelTypeException : public PCLException
00167 {
00168 public:
00169
00170 InvalidSACModelTypeException (const std::string& error_description,
00171 const std::string& file_name = "",
00172 const std::string& function_name = "" ,
00173 unsigned line_number = 0) throw ()
00174 : pcl::PCLException (error_description, file_name, function_name, line_number) { }
00175 } ;
00176
00180 class IOException : public PCLException
00181 {
00182 public:
00183
00184 IOException (const std::string& error_description,
00185 const std::string& file_name = "",
00186 const std::string& function_name = "" ,
00187 unsigned line_number = 0) throw ()
00188 : pcl::PCLException (error_description, file_name, function_name, line_number) { }
00189 } ;
00190
00195 class InitFailedException : public PCLException
00196 {
00197 public:
00198 InitFailedException (const std::string& error_description = "",
00199 const std::string& file_name = "",
00200 const std::string& function_name = "" ,
00201 unsigned line_number = 0) throw ()
00202 : pcl::PCLException (error_description, file_name, function_name, line_number) { }
00203 } ;
00204
00209 class UnorganizedPointCloudException : public PCLException
00210 {
00211 public:
00212
00213 UnorganizedPointCloudException (const std::string& error_description,
00214 const std::string& file_name = "",
00215 const std::string& function_name = "" ,
00216 unsigned line_number = 0) throw ()
00217 : pcl::PCLException (error_description, file_name, function_name, line_number) { }
00218 } ;
00219
00223 class KernelWidthTooSmallException : public PCLException
00224 {
00225 public:
00226
00227 KernelWidthTooSmallException (const std::string& error_description,
00228 const std::string& file_name = "",
00229 const std::string& function_name = "" ,
00230 unsigned line_number = 0) throw ()
00231 : pcl::PCLException (error_description, file_name, function_name, line_number) { }
00232 } ;
00233
00234 class UnhandledPointTypeException : public PCLException
00235 {
00236 public:
00237 UnhandledPointTypeException (const std::string& error_description,
00238 const std::string& file_name = "",
00239 const std::string& function_name = "" ,
00240 unsigned line_number = 0) throw ()
00241 : pcl::PCLException (error_description, file_name, function_name, line_number) { }
00242 };
00243
00244 class ComputeFailedException : public PCLException
00245 {
00246 public:
00247 ComputeFailedException (const std::string& error_description,
00248 const std::string& file_name = "",
00249 const std::string& function_name = "" ,
00250 unsigned line_number = 0) throw ()
00251 : pcl::PCLException (error_description, file_name, function_name, line_number) { }
00252 };
00253
00254 }
00255
00256
00257
00258 #endif