asTranslatedString -> asUserString
authorStanislav Visnovsky <visnov@suse.cz>
Fri, 3 Mar 2006 08:21:05 +0000 (08:21 +0000)
committerStanislav Visnovsky <visnov@suse.cz>
Fri, 3 Mar 2006 08:21:05 +0000 (08:21 +0000)
and use it

zypp/base/Exception.cc
zypp/base/Exception.h
zypp/target/TargetCallbackReceiver.cc
zypp/target/rpm/RpmDb.cc
zypp/target/rpm/librpmDb.cv3.cc

index e172100..2dbbef0 100644 (file)
@@ -13,6 +13,7 @@
 #include <sstream>
 
 #include "zypp/base/Logger.h"
+#include "zypp/base/Gettext.h"
 #include "zypp/base/String.h"
 #include "zypp/base/Exception.h"
 
@@ -57,6 +58,14 @@ namespace zypp
     return str.str();
   }
 
+  std::string Exception::asUserString() const
+  {
+    std::ostringstream str;
+    dumpOn( str );
+    return _(str.str().c_str());
+  }
+
+
   std::ostream & Exception::dumpOn( std::ostream & str ) const
   { return str << _msg; }
 
index 1ea0998..a117428 100644 (file)
@@ -150,7 +150,9 @@ namespace zypp
     /** Error message provided by \ref dumpOn as string. */
     std::string asString() const;
 
-    std::string asTranslatedString() const { return asString(); }
+    /** Translated error message as string suitable for the user. */
+    std::string asUserString() const;
+
   protected:
 
     /** Overload this to print a proper error message. */
@@ -256,6 +258,8 @@ namespace zypp
   ZYPP_THROW( EXCPTTYPE( ::zypp::Exception::strErrno(ERRNO,MSG) ) )
   //@}
 
+#define ZYPP_DUMPON(msg) ( translated ? _(msg) : msg ) 
+
   /////////////////////////////////////////////////////////////////
 } // namespace zypp
 ///////////////////////////////////////////////////////////////////
index 74be912..c33cf79 100644 (file)
@@ -64,7 +64,7 @@ namespace zypp
            rpm::InstallResolvableReport::Action user = 
                _report->problem( _resolvable
                    , rpm::InstallResolvableReport::INVALID
-                   , excpt_r.msg()
+                   , excpt_r.asUserString()
                    , _level
                );
                
@@ -141,7 +141,7 @@ namespace zypp
            rpm::RemoveResolvableReport::Action user = 
                _report->problem( _resolvable
                    , rpm::RemoveResolvableReport::INVALID
-                   , excpt_r.msg()
+                   , excpt_r.asUserString()
                );
                
            switch (user) {
index 74f64dd..75cacac 100644 (file)
@@ -756,7 +756,7 @@ void RpmDb::rebuildDatabase()
   }
   catch (RpmException & excpt_r)
   {
-    report->finish(root() + dbPath(), RebuildDBReport::FAILED, excpt_r.msg());
+    report->finish(root() + dbPath(), RebuildDBReport::FAILED, excpt_r.asUserString());
     ZYPP_RETHROW(excpt_r);
   }
   report->finish(root() + dbPath(), RebuildDBReport::NO_ERROR, "");
@@ -986,7 +986,7 @@ const std::list<Package::Ptr> & RpmDb::getPackages()
   }
   catch (RpmException & excpt_r)
   {
-    report->finish(ScanDBReport::FAILED, excpt_r.msg ());
+    report->finish(ScanDBReport::FAILED, excpt_r.asUserString ());
     ZYPP_RETHROW(excpt_r);
   }
 #warning fixme
index aff98e2..bcc39a4 100644 (file)
@@ -504,7 +504,7 @@ void internal_convertV3toV4( const Pathname & v3db_r, const librpmDb::constPtr &
        }
        catch (RpmException & excpt_r)
        {
-         report->finish(v3db_r, ConvertDBReport::FAILED,excpt_r.msg());
+         report->finish(v3db_r, ConvertDBReport::FAILED,excpt_r.asUserString());
          ZYPP_RETHROW(excpt_r);
        }
         report->finish(v3db_r, ConvertDBReport::NO_ERROR, "");