GEOS  3.6.3
GEOSException.h
1 /**********************************************************************
2  *
3  * GEOS - Geometry Engine Open Source
4  * http://geos.osgeo.org
5  *
6  * Copyright (C) 2001-2002 Vivid Solutions Inc.
7  * Copyright (C) 2006 Refractions Research Inc.
8  *
9  * This is free software; you can redistribute and/or modify it under
10  * the terms of the GNU Lesser General Public Licence as published
11  * by the Free Software Foundation.
12  * See the COPYING file for more information.
13  *
14  **********************************************************************/
15 
16 #ifndef GEOS_UTIL_GEOSEXCEPTION_H
17 #define GEOS_UTIL_GEOSEXCEPTION_H
18 
19 #include <geos/export.h>
20 #include <stdexcept>
21 #include <string>
22 
23 #ifdef _MSC_VER
24 #pragma warning(push)
25 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
26 #pragma warning(disable: 4275) // warning C4275: non-DLL-interface std::exception used as base for DLL-interface GEOSException
27 #endif
28 
29 namespace geos {
30 namespace util { // geos.util
31 
39 class GEOS_DLL GEOSException: public std::exception {
40 
41  std::string _msg;
42 
43 public:
44 
46  :
47  _msg("Unknown error")
48  {}
49 
50  GEOSException(std::string const& msg)
51  :
52  _msg(msg)
53  {}
54 
55  GEOSException(std::string const& name, std::string const& msg)
56  :
57  _msg(name+": "+msg)
58  {}
59 
60  virtual ~GEOSException() throw()
61  {}
62 
63  const char* what() const throw()
64  {
65  return _msg.c_str();
66  }
67 
68 };
69 
70 } // namespace geos.util
71 } // namespace geos
72 
73 #ifdef _MSC_VER
74 #pragma warning(pop)
75 #endif
76 
77 #endif // GEOS_UTIL_GEOSEXCEPTION_H
Base class for all GEOS exceptions.
Definition: GEOSException.h:39