1 /*---------------------------------------------------------------------\
3 | |__ / \ / / . \ . \ |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/base/Exception.cc
15 #include "zypp/base/Logger.h"
16 #include "zypp/base/String.h"
17 #include "zypp/base/Exception.h"
21 ///////////////////////////////////////////////////////////////////
23 { /////////////////////////////////////////////////////////////////
24 ///////////////////////////////////////////////////////////////////
25 namespace exception_detail
26 { /////////////////////////////////////////////////////////////////
28 std::string CodeLocation::asString() const
30 return str::form( "%s(%s):%u",
36 std::ostream & operator<<( std::ostream & str, const CodeLocation & obj )
37 { return str << obj.asString(); }
39 /////////////////////////////////////////////////////////////////
40 } // namespace exception_detail
41 ///////////////////////////////////////////////////////////////////
43 Exception::Exception()
46 Exception::Exception( const std::string & msg_r )
50 Exception::~Exception() throw()
53 std::string Exception::asString() const
55 std::ostringstream str;
60 std::ostream & Exception::dumpOn( std::ostream & str ) const
65 std::ostream & Exception::dumpError( std::ostream & str ) const
67 return dumpOn( str << _where << ": " );
70 std::ostream & operator<<( std::ostream & str, const Exception & obj )
71 { return obj.dumpError( str ); }
73 std::string Exception::strErrno( int errno_r )
75 return str::strerror( errno_r );
78 std::string Exception::strErrno( int errno_r, const std::string & msg_r )
80 std::string ret( msg_r );
82 return ret += strErrno( errno_r );
85 void Exception::log( const Exception & excpt_r, const CodeLocation & where_r,
86 const char *const prefix_r )
88 INT << where_r << " " << prefix_r << " " << excpt_r << endl;
91 /////////////////////////////////////////////////////////////////
93 ///////////////////////////////////////////////////////////////////