1 /*---------------------------------------------------------------------\
3 | |__ / \ / / . \ . \ |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/base/Exception.cc
14 #include "zypp/base/Logger.h"
15 #include "zypp/base/String.h"
16 #include "zypp/base/Exception.h"
20 ///////////////////////////////////////////////////////////////////
22 { /////////////////////////////////////////////////////////////////
23 ///////////////////////////////////////////////////////////////////
24 namespace exceptinon_detail
25 { /////////////////////////////////////////////////////////////////
27 std::string CodeLocation::asString() const
29 return str::form( "%s(%s):%u",
35 std::ostream & operator<<( std::ostream & str, const CodeLocation & obj )
36 { return str << obj.asString(); }
38 /////////////////////////////////////////////////////////////////
39 } // namespace exceptinon_detail
40 ///////////////////////////////////////////////////////////////////
42 Exception::Exception( const CodeLocation & where_r, const std::string & msg_r )
43 : _where( where_r ), _msg( msg_r )
45 INT << asString() << endl;
48 Exception::~Exception() throw()
51 std::string Exception::asString() const
53 std::string ret( _where.asString() );
58 std::string Exception::strErrno( int errno_r )
60 return str::strerror( errno_r );
63 std::string Exception::strErrno( int errno_r, const std::string & msg_r )
65 std::string ret( msg_r );
67 return ret += strErrno( errno_r );
70 void Exception::caught() const
72 INT << "Caught: " << asString() << endl;
75 std::ostream & operator<<( std::ostream & str, const Exception & obj )
76 { return str << obj.asString(); }
78 /////////////////////////////////////////////////////////////////
80 ///////////////////////////////////////////////////////////////////