Changeset 1215


Ignore:
Timestamp:
Oct 10, 2010, 1:41:30 AM (13 years ago)
Author:
Peter Johansson
Message:

extending SVNException to also hold/take svn_error_t. refs #371

Location:
trunk/lib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/SVN.cc

    r1214 r1215  
    3838#include <subversion-1/svn_subst.h>
    3939
     40#include <sstream>
     41#include <string>
     42
    4043namespace theplu {
    4144namespace svndigest {
     45
     46
     47  SVNException::SVNException(const std::string& msg, svn_error_t* error)
     48    : std::runtime_error(""), error_(error), msg_(msg) {}
     49
     50
     51  SVNException::~SVNException(void) throw() {}
     52
     53
     54  const char* SVNException::what(void) const throw()
     55  {
     56    std::stringstream ss;
     57    if (error_) {
     58      apr_size_t bufsize=255;
     59      char buf[255];
     60      ss << svn_err_best_message(error_, buf, bufsize);
     61    }
     62    if (msg_.size()) {
     63      ss << msg_;
     64    }
     65   
     66    return ss.str().c_str();
     67  }
     68
     69
     70  const svn_error_t* SVNException::error(void) const
     71  {
     72    return error_;
     73  }
    4274
    4375
  • trunk/lib/SVN.h

    r978 r1215  
    5050  ///
    5151  struct SVNException : public std::runtime_error
    52   { inline SVNException(const std::string& msg) : runtime_error(msg) {} };
     52  {
     53    SVNException(const std::string& msg, svn_error_t* error=NULL);
     54
     55    virtual ~SVNException(void) throw();
     56    /**
     57       override base implementation
     58     */
     59    const char* what(void) const throw();
     60
     61    /**
     62       access svn_error_t
     63     */
     64    const svn_error_t* error(void) const;
     65  private:
     66    svn_error_t* error_;
     67    std::string msg_;
     68  };
    5369
    5470  /**
Note: See TracChangeset for help on using the changeset viewer.