@@ -67,70 +67,30 @@ template <class Key, class T> bool contains(const std::map<Key, T> &map, const K
6767// Exception classes
6868// ========================================================================
6969
70- // / A base class for all Gambit exceptions
71- class Exception : public std ::runtime_error {
72- public:
73- Exception () : std::runtime_error(" " ) {}
74- explicit Exception (const std::string &s) : std::runtime_error(s) {}
75- ~Exception () noexcept override = default ;
76- };
77-
78- // / Exception thrown on out-of-range index
79- class IndexException : public Exception {
80- public:
81- IndexException () : Exception(" Index out of range" ) {}
82- explicit IndexException (const std::string &s) : Exception(s) {}
83- ~IndexException () noexcept override = default ;
84- };
85-
86- // / Exception thrown on invalid index ranges
87- class RangeException : public Exception {
88- public:
89- RangeException () : Exception(" Invalid index range" ) {}
90- explicit RangeException (const std::string &s) : Exception(s) {}
91- ~RangeException () noexcept override = default ;
92- };
93-
9470// / Exception thrown on dimension mismatches
95- class DimensionException : public Exception {
71+ class DimensionException final : public std::runtime_error {
9672public:
97- DimensionException () : Exception (" Mismatched dimensions" ) {}
98- explicit DimensionException (const std::string &s) : Exception (s) {}
73+ DimensionException () : std::runtime_error (" Mismatched dimensions" ) {}
74+ explicit DimensionException (const std::string &s) : std::runtime_error (s) {}
9975 ~DimensionException () noexcept override = default ;
10076};
10177
10278// / Exception thrown on invalid value
103- class ValueException : public Exception {
79+ class ValueException final : public std::runtime_error {
10480public:
105- ValueException () : Exception (" Invalid value" ) {}
106- explicit ValueException (const std::string &s) : Exception (s) {}
81+ ValueException () : std::runtime_error (" Invalid value" ) {}
82+ explicit ValueException (const std::string &s) : std::runtime_error (s) {}
10783 ~ValueException () noexcept override = default ;
10884};
10985
110- // / Exception thrown on a failed assertion
111- class AssertionException : public Exception {
112- public:
113- AssertionException () : Exception(" Failed assertion" ) {}
114- explicit AssertionException (const std::string &s) : Exception(s) {}
115- ~AssertionException () noexcept override = default ;
116- };
117-
11886// / Exception thrown on attempted division by zero
119- class ZeroDivideException : public Exception {
87+ class ZeroDivideException final : public std::runtime_error {
12088public:
121- ZeroDivideException () : Exception (" Attempted division by zero" ) {}
122- explicit ZeroDivideException (const std::string &s) : Exception (s) {}
89+ ZeroDivideException () : std::runtime_error (" Attempted division by zero" ) {}
90+ explicit ZeroDivideException (const std::string &s) : std::runtime_error (s) {}
12391 ~ZeroDivideException () noexcept override = default ;
12492};
12593
126- // / An exception thrown when attempting to dereference a null pointer
127- class NullException : public Exception {
128- public:
129- NullException () : Exception(" Dereferenced null pointer" ) {}
130- explicit NullException (const std::string &s) : Exception(s) {}
131- ~NullException () noexcept override = default ;
132- };
133-
13494} // end namespace Gambit
13595
13696#endif // GAMBIT_CORE_UTIL_H
0 commit comments