|
Point Cloud Library (PCL)
1.4.0
|
00001 /* 00002 * Software License Agreement (BSD License) 00003 * 00004 * Point Cloud Library (PCL) - www.pointclouds.org 00005 * Copyright (c) 2010-2011, Willow Garage, Inc. 00006 * 00007 * All rights reserved. 00008 * 00009 * Redistribution and use in source and binary forms, with or without 00010 * modification, are permitted provided that the following conditions 00011 * are met: 00012 * 00013 * * Redistributions of source code must retain the above copyright 00014 * notice, this list of conditions and the following disclaimer. 00015 * * Redistributions in binary form must reproduce the above 00016 * copyright notice, this list of conditions and the following 00017 * disclaimer in the documentation and/or other materials provided 00018 * with the distribution. 00019 * * Neither the name of Willow Garage, Inc. nor the names of its 00020 * contributors may be used to endorse or promote products derived 00021 * from this software without specific prior written permission. 00022 * 00023 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00024 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00025 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 00026 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 00027 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 00028 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 00029 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00030 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00031 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00032 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 00033 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00034 * POSSIBILITY OF SUCH DAMAGE. 00035 * 00036 */ 00037 #ifndef PCL_EXCEPTIONS_H_ 00038 #define PCL_EXCEPTIONS_H_ 00039 00040 #include <stdexcept> 00041 #include <pcl/pcl_macros.h> 00042 00043 namespace pcl 00044 { 00045 00050 class PCLException : public std::runtime_error 00051 { 00052 public: 00053 00054 PCLException (const std::string& error_description, 00055 const std::string& file_name = "", 00056 const std::string& function_name = "" , 00057 unsigned line_number = 0) throw () 00058 : std::runtime_error (error_description) 00059 , file_name_ (file_name) 00060 , function_name_ (function_name) 00061 , line_number_ (line_number) 00062 {} 00063 00064 virtual ~PCLException () throw () 00065 {} 00066 00067 const std::string& 00068 getFileName () const throw () 00069 { 00070 return file_name_; 00071 } 00072 00073 const std::string& 00074 getFunctionName () const throw () 00075 { 00076 return function_name_; 00077 } 00078 00079 unsigned 00080 getLineNumber () const throw () 00081 { 00082 return line_number_; 00083 } 00084 00085 std::string 00086 detailedMessage () const throw () 00087 { 00088 std::stringstream sstream; 00089 if (function_name_ != "") 00090 sstream << function_name_ << " "; 00091 00092 if (file_name_ != "") 00093 { 00094 sstream << "in " << file_name_ << " "; 00095 if (line_number_ != 0) 00096 sstream << "@ " << line_number_ << " "; 00097 } 00098 sstream << ":" << what (); 00099 00100 return sstream.str (); 00101 } 00102 00103 protected: 00104 std::string file_name_; 00105 std::string function_name_; 00106 unsigned line_number_; 00107 } ; 00108 00112 class PCL_EXPORTS InvalidConversionException : public PCLException 00113 { 00114 public: 00115 00116 InvalidConversionException (const std::string& error_description, 00117 const std::string& file_name = "", 00118 const std::string& function_name = "" , 00119 unsigned line_number = 0) throw () 00120 : pcl::PCLException (error_description, file_name, function_name, line_number) { } 00121 } ; 00122 00126 class PCL_EXPORTS IsNotDenseException : public PCLException 00127 { 00128 public: 00129 00130 IsNotDenseException (const std::string& error_description, 00131 const std::string& file_name = "", 00132 const std::string& function_name = "" , 00133 unsigned line_number = 0) throw () 00134 : pcl::PCLException (error_description, file_name, function_name, line_number) { } 00135 } ; 00136 00141 class PCL_EXPORTS InvalidSACModelTypeException : public PCLException 00142 { 00143 public: 00144 00145 InvalidSACModelTypeException (const std::string& error_description, 00146 const std::string& file_name = "", 00147 const std::string& function_name = "" , 00148 unsigned line_number = 0) throw () 00149 : pcl::PCLException (error_description, file_name, function_name, line_number) { } 00150 } ; 00151 00155 class PCL_EXPORTS IOException : public PCLException 00156 { 00157 public: 00158 00159 IOException (const std::string& error_description, 00160 const std::string& file_name = "", 00161 const std::string& function_name = "" , 00162 unsigned line_number = 0) throw () 00163 : pcl::PCLException (error_description, file_name, function_name, line_number) { } 00164 } ; 00165 00170 class PCL_EXPORTS InitFailedException : public PCLException 00171 { 00172 public: 00173 InitFailedException (const std::string& error_description = "", 00174 const std::string& file_name = "", 00175 const std::string& function_name = "" , 00176 unsigned line_number = 0) throw () 00177 : pcl::PCLException (error_description, file_name, function_name, line_number) { } 00178 } ; 00179 00184 class PCL_EXPORTS UnorganizedPointCloudException : public PCLException 00185 { 00186 public: 00187 00188 UnorganizedPointCloudException (const std::string& error_description, 00189 const std::string& file_name = "", 00190 const std::string& function_name = "" , 00191 unsigned line_number = 0) throw () 00192 : pcl::PCLException (error_description, file_name, function_name, line_number) { } 00193 } ; 00194 00198 class PCL_EXPORTS KernelWidthTooSmallException : public PCLException 00199 { 00200 public: 00201 00202 KernelWidthTooSmallException (const std::string& error_description, 00203 const std::string& file_name = "", 00204 const std::string& function_name = "" , 00205 unsigned line_number = 0) throw () 00206 : pcl::PCLException (error_description, file_name, function_name, line_number) { } 00207 } ; 00208 00209 } 00210 00216 #define PCL_THROW_EXCEPTION(ExceptionName, message) \ 00217 { \ 00218 std::ostringstream s; \ 00219 s << message; \ 00220 throw ExceptionName(s.str(), __FILE__, "", __LINE__); \ 00221 } 00222 00223 #endif
1.7.6.1