12 #ifndef ZYPP_BASE_EXCEPTION_H 13 #define ZYPP_BASE_EXCEPTION_H 25 namespace exception_detail
43 const std::string & func_r,
60 #define ZYPP_EX_CODELOCATION ::zypp::exception_detail::CodeLocation(( *__FILE__ == '/' ? strrchr( __FILE__, '/' ) + 1 : __FILE__ ),__FUNCTION__,__LINE__) 173 const CodeLocation & where()
const 177 void relocate(
const CodeLocation & where_r )
const 178 { _where = where_r; }
185 const std::string &
msg()
const 206 void remember(
const Exception & old_r );
209 void addHistory(
const std::string & msg_r );
213 {
return _history.begin(); }
217 {
return _history.end(); }
221 {
return _history.empty(); }
225 {
return _history.size(); }
237 std::string historyAsString()
const;
240 std::string asUserHistory()
const;
246 virtual std::ostream &
dumpOn( std::ostream & str )
const;
250 static std::string strErrno(
int errno_r );
252 static std::string strErrno(
int errno_r,
const std::string & msg_r );
258 static void log(
const Exception & excpt_r,
const CodeLocation & where_r,
259 const char *
const prefix_r );
267 virtual const char *
what()
const throw()
268 {
return _msg.c_str(); }
274 std::ostream & dumpError( std::ostream & str )
const;
284 template<
class _Excpt>
286 template<
class _Excpt>
289 excpt_r.relocate( where_r );
295 template<
class _Excpt>
302 template<
class _Excpt>
304 template<
class _Excpt>
308 excpt_r.relocate( where_r );
320 #define ZYPP_THROW(EXCPT)\ 321 _ZYPP_THROW( EXCPT, ZYPP_EX_CODELOCATION ) 324 #define ZYPP_CAUGHT(EXCPT)\ 325 _ZYPP_CAUGHT( EXCPT, ZYPP_EX_CODELOCATION ) 328 #define ZYPP_RETHROW(EXCPT)\ 329 _ZYPP_RETHROW( EXCPT, ZYPP_EX_CODELOCATION ) 333 #define ZYPP_THROW_MSG(EXCPTTYPE, MSG)\ 334 ZYPP_THROW( EXCPTTYPE( MSG ) ) 337 #define ZYPP_THROW_ERRNO(EXCPTTYPE)\ 338 ZYPP_THROW( EXCPTTYPE( ::zypp::Exception::strErrno(errno) ) ) 341 #define ZYPP_THROW_ERRNO1(EXCPTTYPE, ERRNO)\ 342 ZYPP_THROW( EXCPTTYPE( ::zypp::Exception::strErrno(ERRNO) ) ) 345 #define ZYPP_THROW_ERRNO_MSG(EXCPTTYPE, MSG)\ 346 ZYPP_THROW( EXCPTTYPE( ::zypp::Exception::strErrno(errno,MSG) ) ) 349 #define ZYPP_THROW_ERRNO_MSG1(EXCPTTYPE, ERRNO,MSG)\ 350 ZYPP_THROW( EXCPTTYPE( ::zypp::Exception::strErrno(ERRNO,MSG) ) ) 356 #endif // ZYPP_BASE_EXCEPTION_H const std::string & msg() const
Return the message string provided to the ctor.
std::string asUserString(const _Tp &val_r)
Request a human readable (translated) string representation of _Tp [_Tp.asUserString()] Classes may i...
void _ZYPP_THROW(const _Excpt &excpt_r, const exception_detail::CodeLocation &where_r) __attribute__((noreturn))
Helper for ZYPP_THROW macros.
bool historyEmpty() const
Whether the history list is empty.
String related utilities and Regular expression matching.
void relocate(const CodeLocation &where_r) const
Exchange location on rethrow.
virtual const char * what() const
Return message string.
void _ZYPP_CAUGHT(const _Excpt &excpt_r, const exception_detail::CodeLocation &where_r)
Helper for ZYPP_THROW macros.
HistoryIterator historyBegin() const
Iterator pointing to the most recent message.
static void log(const Exception &excpt_r, const CodeLocation &where_r, const char *const prefix_r)
Drop a logline on throw, catch or rethrow.
void _ZYPP_RETHROW(const _Excpt &excpt_r, const exception_detail::CodeLocation &where_r) __attribute__((noreturn))
Helper for ZYPP_THROW macros.
std::list< std::string > History
friend std::ostream & operator<<(std::ostream &str, const CodeLocation &obj)
std::ostream & dumpOn(std::ostream &str, const Capability &obj)
std::string asString() const
Location as string.
CodeLocation(const std::string &file_r, const std::string &func_r, unsigned line_r)
Ctor.
HistoryIterator historyEnd() const
Iterator pointing behind the last message.
Base class for Exception.
History::size_type HistorySize
exception_detail::CodeLocation CodeLocation
Keep FILE, FUNCTION and LINE.
HistorySize historySize() const
The size of the history list.
Easy-to use interface to the ZYPP dependency resolver.
History::const_iterator HistoryIterator