1 #ifndef LIBDNF_ERROR_HPP
2 #define LIBDNF_ERROR_HPP
3 
4 #include <stdexcept>
5 
6 
7 namespace libdnf {
8 
9 /**
10  * A class to use or inherit from for all errors that are expected to happen
11  * (e.g. file not found, permissions, a failed HTTP request, even a corrupted
12  * SQLite database).
13  */
14 class Error : public std::runtime_error {
15 public:
16     using runtime_error::runtime_error;
17 };
18 
19 /**
20  * An unexpected error (that is, really an exception), for errors that
21  * shouldn't occur. Similar in semantics to an assert error, or
22  * std::logic_error (which is misused in the standard library and e.g.
23  * std::stoi throws it as the std::invalid_argument error, which is an error
24  * that can occur under regular circumstances).
25  *
26  * By decision we do not catch these exceptions as of now. By not catching it,
27  * a terminate() is called and a traceback can be retrieved, which is not the
28  * case when the exception is caught. Since these are an unexpected state, a
29  * crash is an acceptable outcome and having the traceback is important for
30  * debugging the issue.
31  *
32  * Therefore, Exception is unrelated to Error (neither inherits from the other).
33  */
34 class Exception : public std::runtime_error {
35 public:
36     using runtime_error::runtime_error;
37 };
38 
39 } // namespace libdnf
40 
41 #endif
42