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 exception_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 exception_detail
40 ///////////////////////////////////////////////////////////////////
42 Exception::Exception( const std::string & msg_r )
46 Exception::~Exception() throw()
49 std::string Exception::asString() const
51 std::string ret( _where.asString() );
56 std::string Exception::strErrno( int errno_r )
58 return str::strerror( errno_r );
61 std::string Exception::strErrno( int errno_r, const std::string & msg_r )
63 std::string ret( msg_r );
65 return ret += strErrno( errno_r );
68 void Exception::log( const Exception & excpt_r, const CodeLocation & where_r,
69 const char *const prefix_r )
71 INT << where_r << " " << prefix_r << " " << excpt_r << endl;
74 std::ostream & Exception::dumpOn( std::ostream & str ) const
76 return str << asString(); // fix it!
79 std::ostream & Exception::dumpError( std::ostream & str ) const
81 return dumpOn( str ); // fix it! prepend location info
84 std::ostream & operator<<( std::ostream & str, const Exception & obj )
85 { return obj.dumpError( str ); }
87 /////////////////////////////////////////////////////////////////
89 ///////////////////////////////////////////////////////////////////