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
61 { return str << _msg; }
63 std::ostream & Exception::dumpError( std::ostream & str ) const
64 { return dumpOn( str << _where << ": " ); }
66 std::ostream & operator<<( std::ostream & str, const Exception & obj )
67 { return obj.dumpError( str ); }
70 std::string Exception::strErrno( int errno_r )
71 { return str::strerror( errno_r ); }
73 std::string Exception::strErrno( int errno_r, const std::string & msg_r )
75 std::string ret( msg_r );
77 return ret += strErrno( errno_r );
80 void Exception::log( const Exception & excpt_r, const CodeLocation & where_r,
81 const char *const prefix_r )
83 INT << where_r << " " << prefix_r << " " << excpt_r << endl;
86 /////////////////////////////////////////////////////////////////
88 ///////////////////////////////////////////////////////////////////