~ubuntu-branches/debian/sid/subversion/sid

« back to all changes in this revision

Viewing changes to subversion/bindings/cxxhl/include/svncxxhl/exception.hpp

  • Committer: Package Import Robot
  • Author(s): James McCoy
  • Date: 2015-08-07 21:32:47 UTC
  • mfrom: (0.2.15) (4.1.7 experimental)
  • Revision ID: package-import@ubuntu.com-20150807213247-ozyewtmgsr6tkewl
Tags: 1.9.0-1
* Upload to unstable
* New upstream release.
  + Security fixes
    - CVE-2015-3184: Mixed anonymous/authenticated path-based authz with
      httpd 2.4
    - CVE-2015-3187: svn_repos_trace_node_locations() reveals paths hidden
      by authz
* Add >= 2.7 requirement for python-all-dev Build-Depends, needed to run
  tests.
* Remove Build-Conflicts against ruby-test-unit.  (Closes: #791844)
* Remove patches/apache_module_dependency in favor of expressing the
  dependencies in authz_svn.load/dav_svn.load.
* Build-Depend on apache2-dev (>= 2.4.16) to ensure ap_some_authn_required()
  is available when building mod_authz_svn and Depend on apache2-bin (>=
  2.4.16) for runtime support.

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
 
36
36
#include "svncxxhl/_compat.hpp"
37
37
 
38
 
// Forward declaration of implementation-specific structure
39
 
struct svn_error_t;
40
 
 
 
38
namespace apache {
41
39
namespace subversion {
42
40
namespace cxxhl {
43
41
 
45
43
 
46
44
namespace detail {
47
45
// Forward declaration of implementation-specific structure
48
 
class error_description;
 
46
class ErrorDescription;
49
47
} // namespace detail
50
48
 
51
 
namespace version_1_9_dev {
52
 
 
53
 
class error : public std::exception
 
49
/**
 
50
 * Exceptions generated by the C++HL implementation.
 
51
 */
 
52
class InternalError : public std::exception
54
53
{
55
54
public:
56
 
  typedef compat::shared_ptr<error> shared_ptr;
57
 
 
58
 
  error(const char* description, int error_code);
59
 
  error(const char* description, int error_code, shared_ptr nested_error);
60
 
 
61
 
  error(const error& that) throw();
62
 
  error& operator=(const error& that) throw();
63
 
  virtual ~error() throw();
64
 
 
65
 
  /**
66
 
   * Returns the error code associated with the exception.
67
 
   */
68
 
  virtual int code() const throw() { return m_errno; }
69
 
 
70
 
  /**
71
 
   * Returns a shared pointer to the nested exception object, if any.
72
 
   */
73
 
  virtual shared_ptr nested() const throw() { return m_nested; }
74
 
 
75
 
  /// Returns the message associated with this exception object.
 
55
  explicit InternalError(const char* description);
 
56
 
 
57
  InternalError(const InternalError& that) throw();
 
58
  InternalError& operator= (const InternalError& that) throw();
 
59
  virtual ~InternalError() throw();
 
60
 
 
61
  /**
 
62
   * Returns the message associated with this exception object.
 
63
   */
76
64
  virtual const char* what() const throw();
77
65
 
 
66
protected:
 
67
  typedef compat::shared_ptr<detail::ErrorDescription> description_ptr;
 
68
  explicit InternalError(description_ptr description) throw();
 
69
  description_ptr m_description;
 
70
};
 
71
 
 
72
/**
 
73
 * Encapsulate a stack of Subversion error codes and messages.
 
74
 */
 
75
class Error : public InternalError
 
76
{
 
77
public:
 
78
  Error(const Error& that) throw();
 
79
  Error& operator=(const Error& that) throw();
 
80
  virtual ~Error() throw();
 
81
 
 
82
  /**
 
83
   * Returns the error code associated with the top-level error that
 
84
   * caused the exception.
 
85
   */
 
86
  virtual int code() const throw();
 
87
 
78
88
  /**
79
89
   * Error message description.
80
 
   *
81
 
   * The first element of this pair is the error code, the second the
82
 
   * associated error message. If the error code is 0, the message
83
 
   * describes the location in the source code where the error was
84
 
   * generated from.
85
90
   */
86
 
  typedef std::pair<int, std::string> message;
 
91
  class Message
 
92
  {
 
93
  public:
 
94
    /**
 
95
     * Create a message object given an error code and error message.
 
96
     */
 
97
    Message(int errval, const std::string& message)
 
98
      : m_errno(errval),
 
99
        m_message(message),
 
100
        m_trace(false)
 
101
      {}
 
102
 
 
103
    /**
 
104
     * Create a message object given an error code and error message,
 
105
     * and set the flag that tells if this is a debugging traceback entry.
 
106
     */
 
107
    Message(int errval, const std::string& message, bool trace)
 
108
      : m_errno(errval),
 
109
        m_message(message),
 
110
        m_trace(trace)
 
111
      {}
 
112
 
 
113
    /**
 
114
     * Return the error code.
 
115
     */
 
116
    int code() const throw() { return m_errno; }
 
117
 
 
118
    /**
 
119
     * Return the error message.
 
120
     */
 
121
    const std::string& message() const throw() { return m_message; }
 
122
 
 
123
    /**
 
124
     * Return the generic error message associated with the error code.
 
125
     */
 
126
    const char* generic_message() const;
 
127
 
 
128
    /**
 
129
     * Check if this message is in fact a debugging traceback entry.
 
130
     */
 
131
    bool trace() const throw() { return m_trace; }
 
132
 
 
133
  private:
 
134
    int m_errno;
 
135
    std::string m_message;
 
136
    bool m_trace;
 
137
  };
87
138
 
88
139
  /**
89
140
   * The list of messages associated with an error.
90
141
   */
91
 
  typedef std::vector<message> message_list;
 
142
  typedef std::vector<Message> MessageList;
92
143
 
93
144
  /**
94
145
   * Returns the complete list of error messages, including those from
95
 
   * nested exceptions.
 
146
   * nested errors.
96
147
   */
97
 
  virtual message_list messages() const
 
148
  virtual MessageList messages() const
98
149
    {
99
150
      return compile_messages(false);
100
151
    }
106
157
   * Traceback is only available if the Subversion libraries were
107
158
   * compiled with tracing enabled.
108
159
   */
109
 
  virtual message_list traced_messages() const
 
160
  virtual MessageList traced_messages() const
110
161
    {
111
162
      return compile_messages(true);
112
163
    }
113
164
 
114
 
public:
115
 
  /** Used internally by the implementation. */
116
 
  static void throw_svn_error(svn_error_t*);
117
 
 
118
165
protected:
119
 
  error(int error_code, detail::error_description* description) throw();
120
 
 
121
 
private:
122
 
  std::vector<message> compile_messages(bool show_traces) const;
123
 
 
124
 
  int m_errno;                /**< The (SVN or APR) error code. */
125
 
  shared_ptr m_nested;        /**< Optional pointer to nessted error. */
126
 
  /** Error description and trace location information. */
127
 
  detail::error_description* m_description;
 
166
  explicit Error(description_ptr description) throw()
 
167
    : InternalError(description)
 
168
    {}
 
169
  MessageList compile_messages(bool show_traces) const;
128
170
};
129
171
 
130
 
class cancelled : public error
 
172
/**
 
173
 * Thrown instead of Error when the error chain contains a
 
174
 * @c SVN_ERR_CANCELLED error code.
 
175
 */
 
176
class Cancelled : public Error
131
177
{
132
 
  friend void error::throw_svn_error(svn_error_t*);
133
 
 
134
178
protected:
135
 
  cancelled(int error_code, detail::error_description* description) throw()
136
 
    : error(error_code, description)
 
179
  explicit Cancelled(description_ptr description) throw()
 
180
    : Error(description)
137
181
    {}
138
182
};
139
183
 
140
 
} // namespace version_1_9_dev
141
184
} // namespace cxxhl
142
185
} // namespace subversion
 
186
} // namespace apache
143
187
 
144
188
#endif  // SVN_CXXHL_EXCEPTION_HPP