libcrn  3.9.5
A document image processing library
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CRNException.h
Go to the documentation of this file.
1 /* Copyright 2007-2014 Yann LEYDIER, CoReNum, INSA-Lyon
2  *
3  * This file is part of libcrn.
4  *
5  * libcrn is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Lesser General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * libcrn is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with libcrn. If not, see <http://www.gnu.org/licenses/>.
17  *
18  * file: CRNException.h
19  * \author Yann LEYDIER, Guillaume ETIEVENT
20  */
21 
22 #ifndef CRNEXCEPTION_HEADER
23 #define CRNEXCEPTION_HEADER
24 
25 #include <CRN.h>
26 #include <exception>
27 #include <string>
28 
32 namespace crn
33 {
34  class StringUTF8;
37 
39  class Exception: public std::exception
40  {
41  public:
43  explicit Exception() noexcept;
45  explicit Exception(const StringUTF8 &msg) noexcept;
47  explicit Exception(const char *msg) noexcept;
49  explicit Exception(const Exception &ex) noexcept;
51  virtual ~Exception() noexcept override;
53  const std::string& GetContext() const noexcept;
55  const std::string& GetMessage() const noexcept;
57  virtual const char* what() const noexcept override;
58 
60  static void SetDefaultHandler();
61 
63  static bool& TraceStack();
64 
65  private:
66  std::string message;
67  std::string context;
68  };
69 
71  class ExceptionLogic: public Exception
72  {
73  public:
75  explicit ExceptionLogic() noexcept;
77  explicit ExceptionLogic(const crn::StringUTF8 &msg) noexcept;
79  explicit ExceptionLogic(const char *msg) noexcept;
80  };
81 
84  {
85  public:
87  explicit ExceptionDomain() noexcept;
89  explicit ExceptionDomain(const crn::StringUTF8 &msg) noexcept;
91  explicit ExceptionDomain(const char *msg) noexcept;
92  };
93 
96  {
97  public:
99  explicit ExceptionNotFound() noexcept;
101  explicit ExceptionNotFound(const crn::StringUTF8 &msg) noexcept;
103  explicit ExceptionNotFound(const char *msg) noexcept;
104  };
105 
108  {
109  public:
111  explicit ExceptionInvalidArgument() noexcept;
113  explicit ExceptionInvalidArgument(const crn::StringUTF8 &msg) noexcept;
115  explicit ExceptionInvalidArgument(const char *msg) noexcept;
116  };
117 
120  {
121  public:
123  explicit ExceptionDimension() noexcept;
125  explicit ExceptionDimension(const crn::StringUTF8 &msg) noexcept;
127  explicit ExceptionDimension(const char *msg) noexcept;
128  };
129 
132  {
133  public:
135  explicit ExceptionRuntime() noexcept;
137  explicit ExceptionRuntime(const crn::StringUTF8 &msg) noexcept;
139  explicit ExceptionRuntime(const char *msg) noexcept;
140  };
141 
144  {
145  public:
147  explicit ExceptionProtocol() noexcept;
149  explicit ExceptionProtocol(const crn::StringUTF8 &msg) noexcept;
151  explicit ExceptionProtocol(const char *msg) noexcept;
152  };
153 
156  {
157  public:
159  explicit ExceptionUninitialized() noexcept;
161  explicit ExceptionUninitialized(const crn::StringUTF8 &msg) noexcept;
163  explicit ExceptionUninitialized(const char *msg) noexcept;
164  };
165 
168  {
169  public:
171  explicit ExceptionTODO() noexcept;
173  explicit ExceptionTODO(const crn::StringUTF8 &msg) noexcept;
175  explicit ExceptionTODO(const char *msg) noexcept;
176  };
177 
180  {
181  public:
183  explicit ExceptionIO() noexcept;
185  explicit ExceptionIO(const crn::StringUTF8 &msg) noexcept;
187  explicit ExceptionIO(const char *msg) noexcept;
188  };
189 
191 }
192 
193 #endif
ExceptionRuntime() noexcept
Default constructor.
virtual ~Exception() noexceptoverride
Destructor.
A generic runtime error.
Definition: CRNException.h:131
const std::string & GetMessage() const noexcept
String containing a description of the exception.
Unintialized object error.
Definition: CRNException.h:155
ExceptionInvalidArgument() noexcept
Default constructor.
ExceptionDimension() noexcept
Default constructor.
A generic logic error.
Definition: CRNException.h:71
A protocol is not implemented.
Definition: CRNException.h:143
A generic domain error.
Definition: CRNException.h:83
ExceptionIO() noexcept
Default constructor.
const std::string & GetContext() const noexcept
String containing the call stack at the moment of throw.
static bool & TraceStack()
Shall the stack be traced at each exception thrown? (very slow)
ExceptionUninitialized() noexcept
Default constructor.
static void SetDefaultHandler()
Sets the default exception handler to print message and context to the standard error.
A dimension error.
Definition: CRNException.h:119
Exception() noexcept
Default constructor.
virtual const char * what() const noexceptoverride
String containing a description of the exception.
ExceptionTODO() noexcept
Default constructor.
A character string class.
Definition: CRNStringUTF8.h:49
ExceptionNotFound() noexcept
Default constructor.
Base class for exceptions.
Definition: CRNException.h:39
I/O error.
Definition: CRNException.h:179
ExceptionLogic() noexcept
Default constructor.
ExceptionDomain() noexcept
Default constructor.
Something to be done.
Definition: CRNException.h:167
Invalid argument error (e.g.: nullptr pointer)
Definition: CRNException.h:107
An item was not found in a container.
Definition: CRNException.h:95
ExceptionProtocol() noexcept
Default constructor.