From 8c2d234a34cfda4534fddc659035056b7dcffd27 Mon Sep 17 00:00:00 2001 From: Stanislav Visnovsky Date: Fri, 3 Mar 2006 08:21:05 +0000 Subject: [PATCH] asTranslatedString -> asUserString and use it --- zypp/base/Exception.cc | 9 +++++++++ zypp/base/Exception.h | 6 +++++- zypp/target/TargetCallbackReceiver.cc | 4 ++-- zypp/target/rpm/RpmDb.cc | 4 ++-- zypp/target/rpm/librpmDb.cv3.cc | 2 +- 5 files changed, 19 insertions(+), 6 deletions(-) diff --git a/zypp/base/Exception.cc b/zypp/base/Exception.cc index e172100..2dbbef0 100644 --- a/zypp/base/Exception.cc +++ b/zypp/base/Exception.cc @@ -13,6 +13,7 @@ #include #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; } diff --git a/zypp/base/Exception.h b/zypp/base/Exception.h index 1ea0998..a117428 100644 --- a/zypp/base/Exception.h +++ b/zypp/base/Exception.h @@ -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 /////////////////////////////////////////////////////////////////// diff --git a/zypp/target/TargetCallbackReceiver.cc b/zypp/target/TargetCallbackReceiver.cc index 74be912..c33cf79 100644 --- a/zypp/target/TargetCallbackReceiver.cc +++ b/zypp/target/TargetCallbackReceiver.cc @@ -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) { diff --git a/zypp/target/rpm/RpmDb.cc b/zypp/target/rpm/RpmDb.cc index 74f64dd..75cacac 100644 --- a/zypp/target/rpm/RpmDb.cc +++ b/zypp/target/rpm/RpmDb.cc @@ -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 & 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 diff --git a/zypp/target/rpm/librpmDb.cv3.cc b/zypp/target/rpm/librpmDb.cv3.cc index aff98e2..bcc39a4 100644 --- a/zypp/target/rpm/librpmDb.cv3.cc +++ b/zypp/target/rpm/librpmDb.cv3.cc @@ -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, ""); -- 2.7.4