libzypp
12.16.5
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
libzypp
Welcome to libzypp
Code Pitfalls - Frequently made mistakes
Code Snippets
Environment Variables
Testing for provided features.
Notes on revisions
Extending ZYpp: Plugins and Hooks
Services
Solver - Vendor protection
Writing and tunning testcases
Libzypp and threads
User data as transaction id
Todo List
Deprecated List
Modules
Namespaces
Classes
Files
File List
zypp
base
Algorithm.h
Backtrace.cc
Backtrace.h
Collector.h
Counter.h
Debug.h
DefaultIntegral.h
DtorReset.h
Easy.h
Errno.h
Exception.cc
Exception.h
ExternalDataSource.cc
ExternalDataSource.h
Fd.cc
Fd.h
Flags.h
Function.h
Functional.h
Gettext.cc
Gettext.h
GzStream.cc
GzStream.h
InputStream.cc
InputStream.h
InterProcessMutex.cc
InterProcessMutex.h
IOStream.cc
IOStream.h
Iterator.h
LogControl.cc
LogControl.h
Logger.h
LogTools.h
Measure.cc
Measure.h
NamedValue.h
NonCopyable.h
ProfilingFormater.cc
ProfilingFormater.h
ProvideNumericId.h
PtrTypes.h
Random.cc
Random.h
ReferenceCounted.cc
ReferenceCounted.h
Regex.cc
Regex.h
SafeBool.h
SerialNumber.cc
SerialNumber.h
Signal.h
String.cc
String.h
StrMatcher.cc
StrMatcher.h
Sysconfig.cc
Sysconfig.h
Tr1hash.h
Unit.cc
Unit.h
UserRequestException.cc
UserRequestException.h
WatchFile.h
media
misc
parser
pool
repo
sat
solver
target
thread
ui
url
ws
zypp_detail
APIConfig.h
Arch.cc
Arch.h
AutoDispose.h
Bit.h
ByteCount.cc
ByteCount.h
Callback.h
Capabilities.cc
Capabilities.h
Capability.cc
Capability.h
CapMatch.cc
CapMatch.h
Changelog.cc
Changelog.h
CheckSum.cc
CheckSum.h
CountryCode.cc
CountryCode.h
Date.cc
Date.h
Dep.cc
Dep.h
Digest.cc
Digest.h
DiskUsage.cc
DiskUsage.h
DiskUsageCounter.cc
DiskUsageCounter.h
DownloadMode.cc
DownloadMode.h
Edition.cc
Edition.h
ExternalProgram.cc
ExternalProgram.h
Fetcher.cc
Fetcher.h
FileChecker.cc
FileChecker.h
Filter.h
Glob.cc
Glob.h
HistoryLog.cc
HistoryLog.h
HistoryLogData.cc
HistoryLogData.h
IdString.cc
IdString.h
IdStringType.h
InstanceId.cc
InstanceId.h
KeyContext.h
KeyRing.cc
KeyRing.h
KVMap.h
LanguageCode.cc
LanguageCode.h
Locale.cc
Locale.h
Locks.cc
Locks.h
ManagedFile.h
MediaProducts.cc
MediaProducts.h
MediaSetAccess.cc
MediaSetAccess.h
Misc.h
OnMediaLocation.cc
OnMediaLocation.h
Package.cc
Package.h
PackageKeyword.h
Patch.cc
Patch.h
PathInfo.cc
PathInfo.h
Pathname.cc
Pathname.h
Pattern.cc
Pattern.h
PluginFrame.cc
PluginFrame.h
PluginFrameException.cc
PluginFrameException.h
PluginScript.cc
PluginScript.h
PluginScriptException.cc
PluginScriptException.h
PoolItem.cc
PoolItem.h
PoolItemBest.cc
PoolItemBest.h
PoolQuery.cc
PoolQuery.h
PoolQueryResult.cc
PoolQueryResult.h
PoolQueryUtil.tcc
ProblemSolution.cc
ProblemSolution.h
ProblemTypes.h
Product.cc
Product.h
ProgressData.cc
ProgressData.h
ProvideFilePolicy.cc
ProvideFilePolicy.h
PublicKey.cc
PublicKey.h
Range.cc
Range.h
Rel.cc
Rel.h
RelCompare.h
RepoInfo.cc
RepoInfo.h
RepoManager.cc
RepoManager.h
Repository.cc
Repository.h
RepoStatus.cc
RepoStatus.h
ResFilters.h
ResKind.cc
ResKind.h
ResObject.cc
ResObject.h
ResObjects.h
Resolvable.cc
Resolvable.h
Resolver.cc
Resolver.h
ResolverProblem.cc
ResolverProblem.h
ResPool.cc
ResPool.h
ResPoolProxy.cc
ResPoolProxy.h
ResStatus.cc
ResStatus.h
ResTraits.h
ServiceInfo.cc
ServiceInfo.h
Signature.cc
Signature.h
SrcPackage.cc
SrcPackage.h
SysContent.cc
SysContent.h
Target.cc
Target.h
TmpPath.cc
TmpPath.h
TriBool.h
Url.cc
Url.h
Vendor.h
VendorAttr.cc
VendorAttr.h
VendorSupportOptions.cc
VendorSupportOptions.h
ZConfig.cc
ZConfig.h
ZYpp.cc
ZYpp.h
ZYppCallbacks.h
ZYppCommit.h
ZYppCommitPolicy.cc
ZYppCommitPolicy.h
ZYppCommitResult.cc
ZYppCommitResult.h
ZYppFactory.cc
ZYppFactory.h
File Members
Exception.cc
Go to the documentation of this file.
1
/*---------------------------------------------------------------------\
2
| ____ _ __ __ ___ |
3
| |__ / \ / / . \ . \ |
4
| / / \ V /| _/ _/ |
5
| / /__ | | | | | | |
6
| /_____||_| |_| |_| |
7
| |
8
\---------------------------------------------------------------------*/
12
#include <iostream>
13
#include <sstream>
14
15
#include "
zypp/base/Logger.h
"
16
#include "
zypp/base/LogTools.h
"
17
#include "
zypp/base/Gettext.h
"
18
#include "
zypp/base/String.h
"
19
#include "
zypp/base/Exception.h
"
20
21
using
std::endl;
22
24
namespace
zypp
25
{
26
27
namespace
exception_detail
28
{
29
30
std::string
CodeLocation::asString
()
const
31
{
32
return
str::form
(
"%s(%s):%u"
,
33
_file
.c_str(),
34
_func
.c_str(),
35
_line
);
36
}
37
38
std::ostream &
operator<<
( std::ostream & str,
const
CodeLocation
& obj )
39
{
return
str << obj.
asString
(); }
40
42
}
// namespace exception_detail
44
45
Exception::Exception
()
46
{}
47
48
Exception::Exception
(
const
std::string & msg_r )
49
: _msg( msg_r )
50
{}
51
52
Exception::Exception
(
const
std::string & msg_r,
const
Exception
& history_r )
53
: _msg( msg_r )
54
{
remember
( history_r ); }
55
56
Exception::~Exception
() throw()
57
{}
58
59
std::string
Exception::asString
()
const
60
{
61
std::ostringstream str;
62
dumpOn
( str );
63
return
str.str();
64
}
65
66
std::string
Exception::asUserString
()
const
67
{
68
std::ostringstream str;
69
dumpOn
( str );
70
// call gettext to translate the message. This will
71
// not work if dumpOn() uses composed messages.
72
return
_
(str.str().c_str());
73
}
74
75
std::string
Exception::asUserHistory
()
const
76
{
77
if
(
historyEmpty
() )
78
return
asUserString
();
79
80
std::string ret(
asUserString
() );
81
if
( ret.empty() )
82
return
historyAsString
();
83
84
ret +=
'\n'
;
85
ret +=
historyAsString
();
86
return
ret;
87
}
88
89
void
Exception::remember
(
const
Exception
& old_r )
90
{
91
if
( &old_r !=
this
)
// no self-remember
92
{
93
History
newh( old_r.
_history
.begin(), old_r.
_history
.end() );
94
newh.push_front( old_r.
asUserString
() );
95
_history
.swap( newh );
96
}
97
}
98
99
void
Exception::addHistory
(
const
std::string & msg_r )
100
{
101
_history
.push_front( msg_r );
102
}
103
104
std::string
Exception::historyAsString
()
const
105
{
106
// TranslatorExplanation followed by the list of error messages that lead to this exception
107
std::string history(
_
(
"History:"
) );
108
std::ostringstream ret;
109
dumpRange
( ret,
historyBegin
(),
historyEnd
(),
110
""
, history+
"\n - "
,
"\n - "
,
"\n"
,
""
);
111
return
ret.str();
112
}
113
114
std::ostream &
Exception::dumpOn
( std::ostream & str )
const
115
{
return
str <<
_msg
; }
116
117
std::ostream &
Exception::dumpError
( std::ostream & str )
const
118
{
return
dumpOn
( str <<
_where
<<
": "
); }
119
120
std::ostream &
operator<<
( std::ostream & str,
const
Exception
& obj )
121
{
return
obj.
dumpError
( str ); }
122
123
124
std::string
Exception::strErrno
(
int
errno_r )
125
{
return
str::strerror
( errno_r ); }
126
127
std::string
Exception::strErrno
(
int
errno_r,
const
std::string & msg_r )
128
{
129
std::string ret( msg_r );
130
ret +=
": "
;
131
return
ret +=
strErrno
( errno_r );
132
}
133
134
void
Exception::log
(
const
Exception
& excpt_r,
const
CodeLocation
& where_r,
135
const
char
*
const
prefix_r )
136
{
137
INT
<< where_r <<
" "
<< prefix_r <<
" "
<< excpt_r.
asUserHistory
() << endl;
138
}
139
141
}
// namespace zypp
zypp
base
Exception.cc
Generated by
1.8.2