You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by br...@apache.org on 2013/07/11 03:44:32 UTC
svn commit: r1502086 - in /subversion/trunk/subversion/bindings/cxxhl:
include/svncxxhl/exception.hpp src/exception.cpp
Author: brane
Date: Thu Jul 11 01:44:32 2013
New Revision: 1502086
URL: http://svn.apache.org/r1502086
Log:
C++HL Infrastructure: Insert an InternalError base class
into the exception hierarchy.
* subversion/bindings/cxxhl/include/svncxxhl/exception.hpp
(InternalError): New class. Derives from std::exception.
(Error): Derive from InternalError instead of std::exception.
(Cancelled): Add docstring.
* subversion/bindings/cxxhl/src/exception.cpp
(InternalError): Implement.
(Error): Update implementation.
Modified:
subversion/trunk/subversion/bindings/cxxhl/include/svncxxhl/exception.hpp
subversion/trunk/subversion/bindings/cxxhl/src/exception.cpp
Modified: subversion/trunk/subversion/bindings/cxxhl/include/svncxxhl/exception.hpp
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/cxxhl/include/svncxxhl/exception.hpp?rev=1502086&r1=1502085&r2=1502086&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/cxxhl/include/svncxxhl/exception.hpp (original)
+++ subversion/trunk/subversion/bindings/cxxhl/include/svncxxhl/exception.hpp Thu Jul 11 01:44:32 2013
@@ -49,7 +49,34 @@ namespace detail {
class ErrorDescription;
} // namespace detail
-class Error : public std::exception
+/**
+ * Exceptions generated by the C++HL implementation.
+ */
+class InternalError : public std::exception
+{
+public:
+ InternalError(const char* description);
+
+ InternalError(const InternalError& that) throw();
+ InternalError& operator= (const InternalError& that) throw();
+ virtual ~InternalError() throw();
+
+ /**
+ * Returns the message associated with this exception object.
+ */
+ virtual const char* what() const throw();
+
+protected:
+ InternalError(detail::ErrorDescription* description) throw();
+
+ /** Error description and trace location information. */
+ detail::ErrorDescription* m_description;
+};
+
+/**
+ * Encapsulate a stack of Subversion error codes and messages.
+ */
+class Error : public InternalError
{
public:
typedef compat::shared_ptr<Error> shared_ptr;
@@ -71,9 +98,6 @@ public:
*/
virtual shared_ptr nested() const throw() { return m_nested; }
- /// Returns the message associated with this exception object.
- virtual const char* what() const throw();
-
/**
* Error message description.
*
@@ -122,15 +146,16 @@ private:
int m_errno; /**< The (SVN or APR) error code. */
shared_ptr m_nested; /**< Optional pointer to nessted error. */
- /** Error description and trace location information. */
- detail::ErrorDescription* m_description;
};
+/**
+ * Thrown instead of Error when the error chain contains a
+ * @c SVN_ERR_CANCELLED error code.
+ */
class Cancelled : public Error
{
- friend void Error::throw_svn_error(svn_error_t*);
-
protected:
+ friend void Error::throw_svn_error(svn_error_t*);
Cancelled(int error_code, detail::ErrorDescription* description) throw()
: Error(error_code, description)
{}
Modified: subversion/trunk/subversion/bindings/cxxhl/src/exception.cpp
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/cxxhl/src/exception.cpp?rev=1502086&r1=1502085&r2=1502086&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/cxxhl/src/exception.cpp (original)
+++ subversion/trunk/subversion/bindings/cxxhl/src/exception.cpp Thu Jul 11 01:44:32 2013
@@ -113,23 +113,64 @@ private:
} // namespace detail
+//
+// Class InternalError
+//
+
+InternalError::InternalError(const char* description)
+ : m_description(detail::ErrorDescription::create(description)->reference())
+{}
+
+InternalError::InternalError(const InternalError& that) throw()
+ : m_description(that.m_description->reference())
+{}
+
+InternalError& InternalError::operator=(const InternalError& that) throw()
+{
+ if (this == &that)
+ return *this;
+
+ // This in-place destroy+copy implementation of the assignment
+ // operator is safe because both the destructor and the copy
+ // constructor do not throw exceptions.
+ this->~InternalError();
+ return *new(this) InternalError(that);
+}
+
+InternalError::~InternalError() throw()
+{
+ m_description->dereference();
+}
+
+const char* InternalError::what() const throw()
+{
+ return m_description->what();
+}
+
+InternalError::InternalError(detail::ErrorDescription* description) throw()
+ : m_description(description)
+{}
+
+//
+// Class Error
+//
Error::Error(const char* description, int error_code)
- : m_errno(error_code),
- m_description(detail::ErrorDescription::create(description)->reference())
+ : InternalError(description),
+ m_errno(error_code)
{}
Error::Error(const char* description, int error_code,
Error::shared_ptr nested_error)
- : m_errno(error_code),
- m_nested(nested_error),
- m_description(detail::ErrorDescription::create(description)->reference())
+ : InternalError(description),
+ m_errno(error_code),
+ m_nested(nested_error)
{}
Error::Error(const Error& that) throw()
- : m_errno(that.m_errno),
- m_nested(that.m_nested),
- m_description(that.m_description->reference())
+ : InternalError(that.m_description->reference()),
+ m_errno(that.m_errno),
+ m_nested(that.m_nested)
{}
Error& Error::operator=(const Error& that) throw()
@@ -144,19 +185,11 @@ Error& Error::operator=(const Error& tha
return *new(this) Error(that);
}
-Error::~Error() throw()
-{
- m_description->dereference();
-}
-
-const char* Error::what() const throw()
-{
- return m_description->what();
-}
+Error::~Error() throw() {}
Error::Error(int error_code, detail::ErrorDescription* description) throw()
- : m_errno(error_code),
- m_description(description)
+ : InternalError(description),
+ m_errno(error_code)
{}
void Error::throw_svn_error(svn_error_t* err)