12#ifndef ZYPP_BASE_EXCEPTION_H 
   13#define ZYPP_BASE_EXCEPTION_H 
   69#define ZYPP_EX_CODELOCATION ::zypp::exception_detail::CodeLocation(( *__FILE__ == '/' ? strrchr( __FILE__, '/' ) + 1 : __FILE__ ),__FUNCTION__,__LINE__) 
   72    std::ostream & 
operator<<( std::ostream & 
str, 
const CodeLocation & obj );
 
  199    { 
_where = std::move(where_r); }
 
 
  206    const std::string & 
msg()
 const 
 
  227    void remember( 
const Exception & old_r );
 
  232    void remember( std::exception_ptr old_r );
 
  245    void addHistory( 
const std::string & msg_r );
 
  247    void addHistory( std::string && msg_r );
 
  250    template<
class TContainer>
 
  253      for ( 
const std::string & el : msgc_r )
 
 
  257    template<
class TContainer>
 
  260      for ( std::string & el : msgc_r )
 
 
  290    std::string historyAsString() 
const;
 
  293    std::string asUserHistory() 
const;
 
  299    virtual std::ostream & 
dumpOn( std::ostream & 
str ) 
const;
 
  303    static std::string strErrno( 
int errno_r );
 
  305    static std::string strErrno( 
int errno_r, std::string msg_r );
 
  311    static void log( 
const Exception & excpt_r, 
const CodeLocation & where_r,
 
  312                     const char *
const prefix_r );
 
  314    static void log( 
const char * typename_r, 
const CodeLocation & where_r,
 
  315                     const char *
const prefix_r );
 
  322    const char * 
what() 
const throw()
 override 
  323    { 
return _msg.c_str(); }
 
 
  329    std::ostream & dumpError( std::ostream & 
str ) 
const;
 
 
  340  namespace exception_detail
 
  343    template<
class TExcpt>
 
  347    template<
class TExcpt>
 
  352    template<
class TExcpt, EnableIfIsException<TExcpt> = 0>
 
  354    template<
class TExcpt, EnableIfIsException<TExcpt>>
 
  357      excpt_r.relocate( where_r );
 
 
  362    template<
class TExcpt, EnableIfIsException<TExcpt> = 0>
 
  363    void do_ZYPP_THROW( 
const TExcpt & excpt_r, CodeLocation && where_r ) __attribute__((noreturn));
 
  364    template<
class TExcpt, EnableIfIsException<TExcpt>>
 
  368      excpt_r.relocate(std::move(where_r) );
 
 
  373    template<
class TExcpt, EnableIfNotException<TExcpt> = 0>
 
  374    void do_ZYPP_THROW( 
const TExcpt & excpt_r, 
const CodeLocation & where_r ) __attribute__((noreturn));
 
  375    template<
class TExcpt, EnableIfNotException<TExcpt>>
 
  383    template<
class TExcpt, EnableIfIsException<TExcpt> = 0>
 
  390    template<
class TExcpt, EnableIfNotException<TExcpt> = 0>
 
  397    void do_ZYPP_CAUGHT ( 
const std::exception_ptr & excpt_r, CodeLocation &&where_r );
 
  401    template<
class TExcpt, EnableIfIsException<TExcpt> = 0>
 
  402    void do_ZYPP_RETHROW( 
const TExcpt & excpt_r, 
const CodeLocation & where_r ) __attribute__((noreturn));
 
  403    template<
class TExcpt, EnableIfIsException<TExcpt>>
 
  407      excpt_r.relocate( where_r );
 
 
  411    template<
class TExcpt, EnableIfIsException<TExcpt> = 0>
 
  412    void do_ZYPP_RETHROW( 
const TExcpt & excpt_r, CodeLocation && where_r ) __attribute__((noreturn));
 
  413    template<
class TExcpt, EnableIfIsException<TExcpt>>
 
  417      excpt_r.relocate( std::move(where_r) );
 
 
  422    template<
class TExcpt, EnableIfNotException<TExcpt> = 0>
 
  423    void do_ZYPP_RETHROW( 
const TExcpt & excpt_r, 
const CodeLocation & where_r ) __attribute__((noreturn));
 
  424    template<
class TExcpt, EnableIfNotException<TExcpt>>
 
  431    void do_ZYPP_RETHROW( 
const std::exception_ptr & excpt_r, 
const CodeLocation & where_r );
 
  434    template<
class TExcpt>
 
  439        excpt_r.relocate( std::move(where_r) );
 
  441        Exception::log( 
typeid(excpt_r).name(), where_r, 
"THROW (EXCPTR):   " );
 
  443      return std::make_exception_ptr<std::decay_t<TExcpt>>( std::forward<TExcpt>(excpt_r) );
 
 
  447    std::exception_ptr 
do_ZYPP_FWD_EXCPT_PTR( 
const std::exception_ptr & excpt_r, CodeLocation &&where_r );
 
  459#define ZYPP_THROW(EXCPT)\ 
  460  ::zypp::exception_detail::do_ZYPP_THROW( EXCPT, ZYPP_EX_CODELOCATION ) 
 
  463#define ZYPP_EXCPT_PTR(EXCPT)\ 
  464  ::zypp::exception_detail::do_ZYPP_EXCPT_PTR( EXCPT, ZYPP_EX_CODELOCATION ) 
 
  467#define ZYPP_FWD_EXCPT(EXCPT)\ 
  468  ::zypp::exception_detail::do_ZYPP_FWD_EXCPT_PTR( EXCPT, ZYPP_EX_CODELOCATION ) 
 
  471#define ZYPP_FWD_CURRENT_EXCPT()\ 
  472  ::zypp::exception_detail::do_ZYPP_FWD_EXCPT_PTR( std::current_exception(), ZYPP_EX_CODELOCATION ) 
 
  475#define ZYPP_CAUGHT(EXCPT)\ 
  476  ::zypp::exception_detail::do_ZYPP_CAUGHT( EXCPT, ZYPP_EX_CODELOCATION ) 
 
  479#define ZYPP_RETHROW(EXCPT)\ 
  480  ::zypp::exception_detail::do_ZYPP_RETHROW( EXCPT, ZYPP_EX_CODELOCATION ) 
 
  484#define ZYPP_THROW_MSG(EXCPTTYPE, MSG)\ 
  485  ZYPP_THROW( EXCPTTYPE( MSG ) ) 
 
  488#define ZYPP_THROW_ERRNO(EXCPTTYPE)\ 
  489  ZYPP_THROW( EXCPTTYPE( ::zypp::Exception::strErrno(errno) ) ) 
 
  492#define ZYPP_THROW_ERRNO1(EXCPTTYPE, ERRNO)\ 
  493  ZYPP_THROW( EXCPTTYPE( ::zypp::Exception::strErrno(ERRNO) ) ) 
 
  496#define ZYPP_THROW_ERRNO_MSG(EXCPTTYPE, MSG)\ 
  497  ZYPP_THROW( EXCPTTYPE( ::zypp::Exception::strErrno(errno,MSG) ) ) 
 
  500#define ZYPP_THROW_ERRNO_MSG1(EXCPTTYPE, ERRNO,MSG)\ 
  501  ZYPP_THROW( EXCPTTYPE( ::zypp::Exception::strErrno(ERRNO,MSG) ) ) 
 
Base class for Exception.
void relocate(CodeLocation &&where_r) const
Exchange location on rethrow.
void addHistory(const std::string &msg_r)
Add some message text to the history.
History::const_iterator HistoryIterator
History::size_type HistorySize
static void log(const Exception &excpt_r, const CodeLocation &where_r, const char *const prefix_r)
Drop a logline on throw, catch or rethrow.
HistoryIterator historyBegin() const
Iterator pointing to the most recent message.
const char * what() const override
Return message string.
const std::string & msg() const
Return the message string provided to the ctor.
void remember(std::string &&msg_r)
exception_detail::CodeLocation CodeLocation
void moveToHistory(TContainer &&msgc_r)
addHistory from string container types (oldest first) moving
HistoryIterator historyEnd() const
Iterator pointing behind the last message.
void addToHistory(const TContainer &msgc_r)
addHistory from string container types (oldest first)
std::list< std::string > History
void relocate(const CodeLocation &where_r) const
Exchange location on rethrow.
HistorySize historySize() const
The size of the history list.
const CodeLocation & where() const
Return CodeLocation.
void remember(const std::string &msg_r)
Remembering a plain string is most probably not wanted - we addHistory.
bool historyEmpty() const
Whether the history list is empty.
typename enable_if< B, T >::type enable_if_t
constexpr bool is_base_of_v
String related utilities and Regular expression matching.
void do_ZYPP_RETHROW(const std::exception_ptr &excpt_r, const CodeLocation &where_r)
std::exception_ptr do_ZYPP_FWD_EXCPT_PTR(const std::exception_ptr &excpt_r, CodeLocation &&where_r)
Helper for ZYPP_FWD_CURRENT_EXCPT().
void do_ZYPP_CAUGHT(const std::exception_ptr &excpt_r, CodeLocation &&where_r)
Helper for std::exception_ptr.
std::exception_ptr do_ZYPP_EXCPT_PTR(TExcpt &&excpt_r, CodeLocation &&where_r)
Helper for ZYPP_EXCPT_PTR( Exception ).
std::enable_if_t< !std::is_base_of_v< Exception, TExcpt >, int > EnableIfNotException
SFINAE: Hide template signature if TExcpt is derived from Exception.
std::enable_if_t< std::is_base_of_v< Exception, TExcpt >, int > EnableIfIsException
SFINAE: Hide template signature unless TExcpt is derived from Exception.
std::ostream & operator<<(std::ostream &str, const CodeLocation &obj)
void do_ZYPP_THROW(const TExcpt &excpt_r, const CodeLocation &where_r) __attribute__((noreturn))
Helper for ZYPP_THROW( Exception ).
Easy-to use interface to the ZYPP dependency resolver.
std::ostream & dumpOn(std::ostream &str, const Capability &obj)
std::ostream & operator<<(std::ostream &str, const SerialNumber &obj)
std::string asUserString(VendorSupportOption opt)
converts the support option to a name intended to be printed to the user.
const Arch Arch_armv7hnl Arch_armv7nhl ZYPP_API
std::string asString(const Patch::Category &obj)
Keep FILE, FUNCTION and LINE.
CodeLocation & operator=(const CodeLocation &)=default
friend std::ostream & operator<<(std::ostream &str, const CodeLocation &obj)
CodeLocation(std::string file_r, std::string func_r, unsigned line_r)
Ctor.
std::string asString() const
Location as string.
CodeLocation(const CodeLocation &)=default
CodeLocation & operator=(CodeLocation &&)=default
CodeLocation(CodeLocation &&)=default