GEOS  3.3.3
GEOSException.h
1 /**********************************************************************
2  * $Id: GEOSException.h 2958 2010-03-29 11:29:40Z mloskot $
3  *
4  * GEOS - Geometry Engine Open Source
5  * http://geos.refractions.net
6  *
7  * Copyright (C) 2001-2002 Vivid Solutions Inc.
8  * Copyright (C) 2006 Refractions Research Inc.
9  *
10  * This is free software; you can redistribute and/or modify it under
11  * the terms of the GNU Lesser General Public Licence as published
12  * by the Free Software Foundation.
13  * See the COPYING file for more information.
14  *
15  **********************************************************************/
16 
17 #ifndef GEOS_UTIL_GEOSEXCEPTION_H
18 #define GEOS_UTIL_GEOSEXCEPTION_H
19 
20 #include <geos/export.h>
21 #include <stdexcept>
22 #include <string>
23 
24 #ifdef _MSC_VER
25 #pragma warning(push)
26 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
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
78 
79 /**********************************************************************
80  * $Log$
81  * Revision 1.4 2006/05/22 15:08:01 strk
82  * Print colon after exception name (as it has always been)
83  *
84  * Revision 1.3 2006/04/05 09:34:20 strk
85  * GEOSException derived from std::exception again, hopefully the correct way now
86  *
87  * Revision 1.2 2006/04/04 08:16:46 strk
88  * Changed GEOSException hierarchy to be derived from std::runtime_exception.
89  * Removed the GEOSException::toString redundant method (use ::what() instead)
90  *
91  * Revision 1.1 2006/03/09 16:46:49 strk
92  * geos::geom namespace definition, first pass at headers split
93  *
94  **********************************************************************/