libosmscout  1.1.1
Exception.h
Go to the documentation of this file.
1 #ifndef OSMSCOUT_UTIL_EXCEPTION_H
2 #define OSMSCOUT_UTIL_EXCEPTION_H
3 
4 /*
5  This source is part of the libosmscout library
6  Copyright (C) 2015 Tim Teulings
7 
8  This library is free software; you can redistribute it and/or
9  modify it under the terms of the GNU Lesser General Public
10  License as published by the Free Software Foundation; either
11  version 2.1 of the License, or (at your option) any later version.
12 
13  This library is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  Lesser General Public License for more details.
17 
18  You should have received a copy of the GNU Lesser General Public
19  License along with this library; if not, write to the Free Software
20  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
22 
23 #include <exception>
24 #include <string>
25 
27 #include <system_error>
28 
29 #if defined(_MSC_VER)
30  #if (_MSC_VER <= 1910)
31  #include <yvals.h>
32  #define OSMSCOUT_NOEXCEPT _NOEXCEPT
33  #else
34  #define OSMSCOUT_NOEXCEPT noexcept
35  #endif
36 #else
37 #define OSMSCOUT_NOEXCEPT noexcept
38 #endif
39 
40 namespace osmscout {
41 
42 #if defined(_MSC_VER)
43 #pragma warning (push)
44 #pragma warning (disable:4275)
45 #endif
46 
47  class OSMSCOUT_API OSMScoutException : public std::exception
48  {
49  public:
50  virtual std::string GetDescription() const;
51  };
52 
53 #if defined(_MSC_VER)
54 #pragma warning (pop)
55 #endif
56 
58  {
59  private:
60  std::string object;
61  std::string description;
62 
63  public:
64  explicit UninitializedException(const std::string& object);
65 
66  const char* what() const OSMSCOUT_NOEXCEPT override;
67 
68  std::string GetObject() const;
69  std::string GetDescription() const override;
70  };
71 
73  {
74  private:
75  std::string filename;
76  std::string semanticError;
77  std::string errorMsg;
78  std::string description;
79 
80  public:
81  IOException(const std::string& filename,
82  const std::string& semanticError,
83  const std::system_error& error);
84  IOException(const std::string& filename,
85  const std::string& semanticError,
86  const std::exception& error);
87  IOException(const std::string& filename,
88  const std::string& semanticError);
89  IOException(const std::string& filename,
90  const std::string& semanticError,
91  const std::string& errorMsg);
92 
93  const char* what() const OSMSCOUT_NOEXCEPT override;
94 
95  std::string GetFilename() const;
96  std::string GetSemanticError() const;
97  std::string GetErrorMsg() const;
98  std::string GetDescription() const override;
99  };
100 }
101 
102 #endif
Definition: Exception.h:47
#define OSMSCOUT_NOEXCEPT
Definition: Exception.h:37
Definition: Exception.h:72
Definition: Area.h:38
#define OSMSCOUT_API
Definition: CoreImportExport.h:45
Definition: Exception.h:57