1 /**
2  *   SFCGAL
3  *
4  *   Copyright (C) 2012-2013 Oslandia <infos@oslandia.com>
5  *   Copyright (C) 2012-2013 IGN (http://www.ign.fr)
6  *
7  *   This library is free software; you can redistribute it and/or
8  *   modify it under the terms of the GNU Library General Public
9  *   License as published by the Free Software Foundation; either
10  *   version 2 of the License, or (at your option) any later version.
11  *
12  *   This library is distributed in the hope that it will be useful,
13  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  *   Library General Public License for more details.
16 
17  *   You should have received a copy of the GNU Library General Public
18  *   License along with this library; if not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 #ifndef _IGN_EXCEPTION_H_
22 #define _IGN_EXCEPTION_H_
23 
24 #include <SFCGAL/config.h>
25 
26 #include <string>
27 
28 #include <boost/exception/all.hpp>
29 #include <boost/format.hpp>
30 
31 namespace SFCGAL {
32 
33 /**
34  * Base SFCGAL Exception
35  *
36  * \code
37  * BOOST_THROW_EXCEPTION( Exception("invalid geometry") );
38  * \endcode
39  */
40 class SFCGAL_API Exception : public virtual boost::exception, public virtual  std::exception {
41 public:
42     Exception() throw();
43     Exception( std::string const& message ) throw();
44     virtual ~Exception() throw();
45 
46     /**
47      * returns the exception message
48      */
49     virtual const char* what() const throw();
50     /**
51      * returns diagnostic information (file, line, etc.)
52      */
53     std::string diagnostic() const throw();
54 protected:
55     std::string _message;
56 };
57 
58 /**
59  * SFCGAL Exception thrown when invalid geometries are found before entering an algo
60  */
61 class SFCGAL_API GeometryInvalidityException : public Exception {
62 public:
GeometryInvalidityException(std::string const & message)63     GeometryInvalidityException( std::string const& message ):
64         Exception( message ) {
65     }
66 
67 };
68 
69 /**
70  * SFCGAL Exception thrown when a function is not implemented
71  */
72 class SFCGAL_API NotImplementedException : public Exception {
73 public:
NotImplementedException(std::string const & message)74     NotImplementedException( std::string const& message ):
75         Exception( message ) {
76     }
77 
78 };
79 
80 /**
81  * SFCGAL Exception thrown when geometry is inapropriate for a function
82  */
83 class SFCGAL_API InappropriateGeometryException : public Exception {
84 public:
InappropriateGeometryException(std::string const & message)85     InappropriateGeometryException( std::string const& message ):
86         Exception( message ) {
87     }
88 
89 };
90 
91 /**
92  * SFCGAL Exception thrown when non finite value is found
93  */
94 class SFCGAL_API NonFiniteValueException : public Exception {
95 public:
NonFiniteValueException(std::string const & message)96     NonFiniteValueException( std::string const& message ):
97         Exception( message ) {
98     }
99 
100 };
101 
102 /**
103  * SFCGAL Exception thrown when parsing WKT
104  */
105 class SFCGAL_API WktParseException : public Exception {
106 public:
WktParseException(std::string const & message)107     WktParseException( std::string const& message ):
108         Exception( message ) {
109     }
110 
111 };
112 
113 } // namespace SFCGAL
114 
115 #endif
116 
117 
118