From 4ba8626ab0121a6103953052ed715a30d864cac7 Mon Sep 17 00:00:00 2001 From: Roman Tsisyk <roman@tsisyk.com> Date: Fri, 14 Feb 2014 13:49:57 +0400 Subject: [PATCH] Use proper types in re-throw logic in box.raise() This fix adds virtual method raise() to Exception classes to throw derived type instead of base. --- src/box/lua/call.cc | 2 +- src/exception.h | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/box/lua/call.cc b/src/box/lua/call.cc index 7ff4224ff0..786954c886 100644 --- a/src/box/lua/call.cc +++ b/src/box/lua/call.cc @@ -342,7 +342,7 @@ lbox_raise(lua_State *L) /* re-throw saved exceptions (if any) */ if (cord()->exc == NULL) return 0; - throw cord()->exc; + cord()->exc->raise(); return 0; } diff --git a/src/exception.h b/src/exception.h index e46e611187..dcf01dc226 100644 --- a/src/exception.h +++ b/src/exception.h @@ -37,6 +37,10 @@ class Exception: public Object { public: void *operator new(size_t size); void operator delete(void*); + virtual void raise() + { + throw this; + } const char * errmsg() const @@ -45,6 +49,7 @@ class Exception: public Object { } virtual void log() const = 0; + virtual ~Exception() {} protected: Exception(const char *file, unsigned line); @@ -63,6 +68,11 @@ class Exception: public Object { class SystemError: public Exception { public: + virtual void raise() + { + throw this; + } + int errnum() const { @@ -87,6 +97,11 @@ class SystemError: public Exception { class ClientError: public Exception { public: + virtual void raise() + { + throw this; + } + virtual void log() const; int -- GitLab