Author: hwright
Date: Tue Sep 21 11:07:10 2010
New Revision: 999309
URL: http://svn.apache.org/viewvc?rev=999309&view=rev
Log:
On the object-model branch:
Add a new error code specifically for C++-specific exceptions, use it, and
extend the Exception handing a bit to allow easier creation of exceptions.
* subversion/bindings/c++/Exception.cpp
(Exception): A couple of new constructors.
(c_err): New.
* subversion/bindings/c++/include/Common.h
(Exception): New constructors.
(c_err): New.
* subversion/include/svn_error_codes.h
(SVN_ERR_CPP_EXCEPTION): New.
Modified:
subversion/branches/object-model/subversion/bindings/c++/Exception.cpp
subversion/branches/object-model/subversion/bindings/c++/include/Common.h
subversion/branches/object-model/subversion/include/svn_error_codes.h
Modified: subversion/branches/object-model/subversion/bindings/c++/Exception.cpp
URL:
http://svn.apache.org/viewvc/subversion/branches/object-model/subversion/bindings/c%2B%2B/Exception.cpp?rev=999309&r1=999308&r2=999309&view=diff
==============================================================================
--- subversion/branches/object-model/subversion/bindings/c++/Exception.cpp
(original)
+++ subversion/branches/object-model/subversion/bindings/c++/Exception.cpp Tue
Sep 21 11:07:10 2010
@@ -88,10 +88,24 @@ Exception::Exception(svn_error_t *err)
}
Exception::Exception(const std::string &message)
- : m_description(message)
+ : m_description(message),
+ m_apr_err(SVN_ERR_CPP_EXCEPTION)
{
}
+Exception::Exception(int apr_err, const std::string &message)
+ : m_description(message),
+ m_apr_err(apr_err)
+{
+}
+
+Exception::Exception(int apr_err)
+ : m_apr_err(apr_err)
+{
+ char buf[256];
+ m_description = svn_strerror(apr_err, buf, sizeof(buf));
+}
+
Exception::~Exception() throw ()
{
}
@@ -114,5 +128,13 @@ Exception::getAPRErr()
return m_apr_err;
}
+svn_error_t *
+Exception::c_err()
+{
+ return svn_error_create(m_apr_err, NULL,
+ m_description.size() > 0 ? m_description.c_str()
+ : NULL);
+}
+
}
Modified:
subversion/branches/object-model/subversion/bindings/c++/include/Common.h
URL:
http://svn.apache.org/viewvc/subversion/branches/object-model/subversion/bindings/c%2B%2B/include/Common.h?rev=999309&r1=999308&r2=999309&view=diff
==============================================================================
--- subversion/branches/object-model/subversion/bindings/c++/include/Common.h
(original)
+++ subversion/branches/object-model/subversion/bindings/c++/include/Common.h
Tue Sep 21 11:07:10 2010
@@ -28,6 +28,7 @@
#include <exception>
#include <string>
+#include <map>
namespace SVN
{
@@ -49,12 +50,16 @@ class Exception : public std::exception
Exception(svn_error_t *err);
Exception(const std::string &message);
+ Exception(int apr_err, const std::string &message);
+ Exception(int apr_err);
virtual ~Exception() throw ();
virtual const char *what() const throw();
const std::string &getSource();
int getAPRErr();
+
+ svn_error_t *c_err();
};
}
Modified: subversion/branches/object-model/subversion/include/svn_error_codes.h
URL:
http://svn.apache.org/viewvc/subversion/branches/object-model/subversion/include/svn_error_codes.h?rev=999309&r1=999308&r2=999309&view=diff
==============================================================================
--- subversion/branches/object-model/subversion/include/svn_error_codes.h
(original)
+++ subversion/branches/object-model/subversion/include/svn_error_codes.h Tue
Sep 21 11:07:10 2010
@@ -1345,6 +1345,11 @@ SVN_ERROR_START
"SQLite busy at transaction rollback; "
"resetting all busy SQLite statements to allow rollback")
+ /** @since New in 1.x */
+ SVN_ERRDEF(SVN_ERR_CPP_EXCEPTION,
+ SVN_ERR_MISC_CATEGORY_START + 35,
+ "An error has occurred in the C++ bindings")
+
/* command-line client errors */
SVN_ERRDEF(SVN_ERR_CL_ARG_PARSING_ERROR,