GEOS  3.6.2
GEOSException.h
00001 /**********************************************************************
00002  *
00003  * GEOS - Geometry Engine Open Source
00004  * http://geos.osgeo.org
00005  *
00006  * Copyright (C) 2001-2002 Vivid Solutions Inc.
00007  * Copyright (C) 2006 Refractions Research Inc.
00008  *
00009  * This is free software; you can redistribute and/or modify it under
00010  * the terms of the GNU Lesser General Public Licence as published
00011  * by the Free Software Foundation. 
00012  * See the COPYING file for more information.
00013  *
00014  **********************************************************************/
00015 
00016 #ifndef GEOS_UTIL_GEOSEXCEPTION_H
00017 #define GEOS_UTIL_GEOSEXCEPTION_H
00018 
00019 #include <geos/export.h>
00020 #include <stdexcept>
00021 #include <string>
00022 
00023 #ifdef _MSC_VER
00024 #pragma warning(push)
00025 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
00026 #pragma warning(disable: 4275) // warning C4275: non-DLL-interface std::exception used as base for DLL-interface GEOSException
00027 #endif
00028 
00029 namespace geos {
00030 namespace util { // geos.util
00031 
00039 class GEOS_DLL GEOSException: public std::exception {
00040 
00041         std::string _msg;
00042 
00043 public:
00044 
00045         GEOSException()
00046                 :
00047                 _msg("Unknown error")
00048         {}
00049 
00050         GEOSException(std::string const& msg)
00051                 :
00052                 _msg(msg)
00053         {}
00054 
00055         GEOSException(std::string const& name, std::string const& msg)
00056                 :
00057                 _msg(name+": "+msg)
00058         {}
00059 
00060         virtual ~GEOSException() throw()
00061         {}
00062 
00063         const char* what() const throw()
00064         {
00065                 return _msg.c_str();
00066         }
00067 
00068 };
00069 
00070 } // namespace geos.util
00071 } // namespace geos
00072 
00073 #ifdef _MSC_VER
00074 #pragma warning(pop)
00075 #endif
00076 
00077 #endif // GEOS_UTIL_GEOSEXCEPTION_H