Add historyAsString()
authorMichael Andres <ma@suse.de>
Fri, 27 Jul 2007 12:05:17 +0000 (12:05 +0000)
committerMichael Andres <ma@suse.de>
Fri, 27 Jul 2007 12:05:17 +0000 (12:05 +0000)
zypp/base/Exception.cc
zypp/base/Exception.h

index 8b745d4..aabd9ab 100644 (file)
@@ -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; }
 
index 71bfd30..9db69a0 100644 (file)
@@ -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: