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;
282 namespace exception_detail
285 template<
class TExcpt>
287 template<
class TExcpt>
290 excpt_r.relocate( where_r );
296 template<
class TExcpt>
303 template<
class TExcpt>
305 template<
class TExcpt>
309 excpt_r.relocate( where_r );
321 #define ZYPP_THROW(EXCPT)\ 322 ::zypp::exception_detail::do_ZYPP_THROW( EXCPT, ZYPP_EX_CODELOCATION ) 325 #define ZYPP_CAUGHT(EXCPT)\ 326 ::zypp::exception_detail::do_ZYPP_CAUGHT( EXCPT, ZYPP_EX_CODELOCATION ) 329 #define ZYPP_RETHROW(EXCPT)\ 330 ::zypp::exception_detail::do_ZYPP_RETHROW( EXCPT, ZYPP_EX_CODELOCATION ) 334 #define ZYPP_THROW_MSG(EXCPTTYPE, MSG)\ 335 ZYPP_THROW( EXCPTTYPE( MSG ) ) 338 #define ZYPP_THROW_ERRNO(EXCPTTYPE)\ 339 ZYPP_THROW( EXCPTTYPE( ::zypp::Exception::strErrno(errno) ) ) 342 #define ZYPP_THROW_ERRNO1(EXCPTTYPE, ERRNO)\ 343 ZYPP_THROW( EXCPTTYPE( ::zypp::Exception::strErrno(ERRNO) ) ) 346 #define ZYPP_THROW_ERRNO_MSG(EXCPTTYPE, MSG)\ 347 ZYPP_THROW( EXCPTTYPE( ::zypp::Exception::strErrno(errno,MSG) ) ) 350 #define ZYPP_THROW_ERRNO_MSG1(EXCPTTYPE, ERRNO,MSG)\ 351 ZYPP_THROW( EXCPTTYPE( ::zypp::Exception::strErrno(ERRNO,MSG) ) ) 357 #endif // ZYPP_BASE_EXCEPTION_H void do_ZYPP_CAUGHT(const TExcpt &excpt_r, const CodeLocation &where_r)
Helper for ZYPP_THROW macros.
const std::string & msg() const
Return the message string provided to the ctor.
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.
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.
std::list< std::string > History
friend std::ostream & operator<<(std::ostream &str, const CodeLocation &obj)
std::ostream & dumpOn(std::ostream &str, const Capability &obj)
void do_ZYPP_RETHROW(const TExcpt &excpt_r, const CodeLocation &where_r) __attribute__((noreturn))
Helper for ZYPP_THROW macros.
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.
void do_ZYPP_THROW(const TExcpt &excpt_r, const CodeLocation &where_r) __attribute__((noreturn))
Helper for ZYPP_THROW macros.
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
std::string asUserString(const Tp &val_r)
Request a human readable (translated) string representation of Tp [Tp.asUserString()] Classes may imp...