return _(str.str().c_str());
}
+ void Exception::remember( const Exception & old_r )
+ {
+ if ( &old_r != this ) // no self-remember
+ {
+ History newh( old_r._history.begin(), old_r._history.end() );
+ newh.push_front( old_r.asUserString() );
+ _history.swap( newh );
+ }
+ }
+
+ void Exception::addHistory( const std::string & msg_r )
+ {
+ _history.push_front( msg_r );
+ }
std::ostream & Exception::dumpOn( std::ostream & str ) const
{ return str << _msg; }
#include <cerrno>
#include <iosfwd>
+#include <list>
#include <stdexcept>
///////////////////////////////////////////////////////////////////
public:
typedef exception_detail::CodeLocation CodeLocation;
+ typedef std::list<std::string> History;
+ typedef History::const_iterator HistoryIterator;
+ typedef History::size_type HistorySize;
/** Default ctor.
* Use \ref ZYPP_THROW to throw exceptions.
/** Translated error message as string suitable for the user. */
std::string asUserString() const;
+ public:
+ /** \name History list of message strings.
+ * Maintain a simple list of individual error messages, that lead
+ * to this Exception. The Exceptions message itself is not included
+ * in the history. The History list stores the most recent message
+ * fist.
+ */
+ //@{
+
+ /** Store an other Exception as history. */
+ void remember( const Exception & old_r );
+
+ /** Add some message text to the history. */
+ void addHistory( const std::string & msg_r );
+
+ /** */
+ HistoryIterator historyBegin() const
+ { return _history.begin(); }
+
+ /** */
+ HistoryIterator historyEnd() const
+ { return _history.end(); }
+
+ /** */
+ bool historyEmpty() const
+ { return _history.empty(); }
+
+ /** */
+ HistorySize historySize() const
+ { return _history.size(); }
+
+ //@}
+
protected:
/** Overload this to print a proper error message. */
private:
mutable CodeLocation _where;
- std::string _msg;
+ std::string _msg;
+ History _history;
/** Return message string. */
virtual const char * what() const throw()