Orcus
exception.hpp
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This Source Code Form is subject to the terms of the Mozilla Public
4  * License, v. 2.0. If a copy of the MPL was not distributed with this
5  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
6  */
7 
8 #ifndef INCLUDED_ORCUS_EXCEPTION_HPP
9 #define INCLUDED_ORCUS_EXCEPTION_HPP
10 
11 #include <stdexcept>
12 #include <string>
13 
14 #include "env.hpp"
15 
16 namespace orcus {
17 
18 class ORCUS_PSR_DLLPUBLIC general_error : public std::exception
19 {
20 public:
21  explicit general_error(std::string msg);
22  explicit general_error(std::string_view cls, std::string_view msg);
23  virtual ~general_error() noexcept;
24  virtual const char* what() const noexcept;
25 
26 protected:
27  void append_msg(const std::string& s);
28 
29 private:
30  std::string m_msg;
31 };
32 
33 class ORCUS_PSR_DLLPUBLIC invalid_arg_error : public std::invalid_argument
34 {
35 public:
36  explicit invalid_arg_error(const std::string& msg);
37  virtual ~invalid_arg_error() noexcept;
38 };
39 
40 class ORCUS_PSR_DLLPUBLIC xml_structure_error : public general_error
41 {
42 public:
43  explicit xml_structure_error(std::string msg);
44  virtual ~xml_structure_error() noexcept;
45 };
46 
47 class ORCUS_PSR_DLLPUBLIC json_structure_error : public general_error
48 {
49 public:
50  explicit json_structure_error(std::string msg);
51  virtual ~json_structure_error() noexcept;
52 };
53 
54 class ORCUS_PSR_DLLPUBLIC invalid_map_error : public general_error
55 {
56 public:
57  explicit invalid_map_error(std::string msg);
58  virtual ~invalid_map_error() noexcept;
59 };
60 
61 class ORCUS_PSR_DLLPUBLIC value_error : public general_error
62 {
63 public:
64  explicit value_error(std::string msg);
65  virtual ~value_error() noexcept;
66 };
67 
71 class ORCUS_PSR_DLLPUBLIC xpath_error : public general_error
72 {
73 public:
74  xpath_error(std::string msg);
75  virtual ~xpath_error() noexcept;
76 };
77 
82 class ORCUS_PSR_DLLPUBLIC interface_error : public general_error
83 {
84 public:
85  interface_error(std::string msg);
86  virtual ~interface_error() noexcept;
87 };
88 
93 class ORCUS_PSR_DLLPUBLIC parse_error : public general_error
94 {
95  std::ptrdiff_t m_offset;
96 
97 protected:
98  parse_error(std::string_view cls, std::string_view msg, std::ptrdiff_t offset);
99 
100 public:
101  parse_error(std::string msg, std::ptrdiff_t offset);
102 
108  std::ptrdiff_t offset() const;
109 
110  static void throw_with(
111  std::string_view msg_before, char c, std::string_view msg_after, std::ptrdiff_t offset);
112 
113  static void throw_with(
114  std::string_view msg_before, std::string_view msg, std::string_view msg_after, std::ptrdiff_t offset);
115 };
116 
120 class ORCUS_PSR_DLLPUBLIC malformed_xml_error : public parse_error
121 {
122 public:
123  malformed_xml_error() = delete;
124  malformed_xml_error(std::string_view msg, std::ptrdiff_t offset);
125  virtual ~malformed_xml_error();
126 };
127 
131 class ORCUS_PSR_DLLPUBLIC zip_error : public general_error
132 {
133 public:
134  zip_error(std::string_view msg);
135  virtual ~zip_error();
136 };
137 
138 namespace detail {
139 
144 class ORCUS_PSR_DLLPUBLIC parsing_aborted_error : public std::exception {};
145 
146 }
147 
148 }
149 
150 #endif
151 
152 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Definition: exception.hpp:144
Definition: exception.hpp:19
Definition: exception.hpp:83
Definition: exception.hpp:34
Definition: exception.hpp:55
Definition: exception.hpp:48
Definition: exception.hpp:121
Definition: exception.hpp:94
std::ptrdiff_t offset() const
parse_error(std::string_view cls, std::string_view msg, std::ptrdiff_t offset)
offset in the stream where the error occurred.
Definition: exception.hpp:62
Definition: exception.hpp:41
Definition: exception.hpp:72
Definition: exception.hpp:132