From d159fb64ce43bb30a5705c6b6f29b727ac87b1b5 Mon Sep 17 00:00:00 2001 From: Michael Andres Date: Fri, 27 Jul 2007 12:05:17 +0000 Subject: [PATCH] Add historyAsString() --- zypp/base/Exception.cc | 10 ++++++++++ zypp/base/Exception.h | 20 ++++++++++++++++---- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/zypp/base/Exception.cc b/zypp/base/Exception.cc index 8b745d4..aabd9ab 100644 --- a/zypp/base/Exception.cc +++ b/zypp/base/Exception.cc @@ -82,6 +82,16 @@ namespace zypp _history.push_front( msg_r ); } + std::string Exception::historyAsString() const + { + // TranslatorExplanation followed by the list of error messages that lead to this exception + std::string history( _("History:") ); + ostringstream ret; + dumpRange( ret, err.historyBegin(), err.historyEnd(), + "", history+"\n - ", "\n - ", "\n", "" ); + return ret.str(); + } + std::ostream & Exception::dumpOn( std::ostream & str ) const { return str << _msg; } diff --git a/zypp/base/Exception.h b/zypp/base/Exception.h index 71bfd30..9db69a0 100644 --- a/zypp/base/Exception.h +++ b/zypp/base/Exception.h @@ -173,22 +173,34 @@ namespace zypp /** Add some message text to the history. */ void addHistory( const std::string & msg_r ); - /** */ + /** Iterator pointing to the most recent message. */ HistoryIterator historyBegin() const { return _history.begin(); } - /** */ + /** Iterator pointing behind the last message. */ HistoryIterator historyEnd() const { return _history.end(); } - /** */ + /** Whether the history list is empty. */ bool historyEmpty() const { return _history.empty(); } - /** */ + /** The size of the history list. */ HistorySize historySize() const { return _history.size(); } + /** The history as string. Empty if \ref historyEmpty. + * Otherwise: + * \code + * History: + * - most recent message + * - 2nd message + * ... + * - oldest message + * \endcode + */ + std::string historyAsString() const; + //@} protected: -- 2.7.4