Skip to content

Commit 0b90ff9

Browse files
committed
Changed runtime_error int ptr.hpp to dot::exception.
(cherry picked from commit 63096dcc3e118a86091a1bc96e3db0d1ab52ecf5) (cherry picked from commit bd77fe359f31c01aa1b94301503fd49aeef160c1)
1 parent 41c628c commit 0b90ff9

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

‎cpp/src/dotcpp/dot/system/ptr.hpp‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,12 @@ limitations under the License.
2525

2626
#include <dot/declare.hpp>
2727
#include <dot/detail/reference_counter.hpp>
28+
#include <dot/system/exception.hpp>
2829

2930
namespace dot
3031
{
3132
class Null;
33+
class exception;
3234

3335
/// <summary>
3436
/// Reference counted smart pointer based on std::shared_ptr
@@ -148,7 +150,8 @@ namespace dot
148150
T* p = dynamic_cast<T*>(rhs.ptr_);
149151

150152
// Check that dynamic cast succeeded
151-
if (!p) throw std::runtime_error("Cast cannot be performed."); // TODO Use typeof(...) and type() to provide specific types in the error message
153+
if (!p)
154+
throw dot::exception("Cast cannot be performed."); // TODO Use typeof(...) and type() to provide specific types in the error message
152155

153156
// Current pointer now contains the result of dynamic_cast
154157
ptr_ = p;
@@ -164,13 +167,13 @@ namespace dot
164167
template <class T> T& ptr<T>::operator*() const
165168
{
166169
if (!ptr_)
167-
throw std::runtime_error("Pointer is not initialized");
170+
throw std::exception("Pointer is not initialized");
168171
return *ptr_;
169172
}
170173
template <class T> T* ptr<T>::operator->() const
171174
{
172175
if (!ptr_)
173-
throw std::runtime_error("Pointer is not initialized");
176+
throw std::exception("Pointer is not initialized");
174177
return ptr_;
175178
}
176179
template <class T> bool ptr<T>::operator==(const ptr<T>& rhs) const { return ptr_ == rhs.ptr_; } // TODO check when comparison is performed by value

0 commit comments

Comments
 (0)