12 #ifndef ZYPP_BASE_EXCEPTION_H
13 #define ZYPP_BASE_EXCEPTION_H
26 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__)
63 std::ostream &
operator<<( std::ostream & str,
const CodeLocation & obj );
185 const std::string &
msg()
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 );
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;
279 std::ostream &
operator<<( std::ostream & str,
const Exception & obj );
284 template<
class _Excpt>
285 void _ZYPP_THROW(
const _Excpt & excpt_r,
const exception_detail::CodeLocation & where_r ) __attribute__((noreturn));
286 template<
class _Excpt>
289 excpt_r.relocate( where_r );
295 template<
class _Excpt>
302 template<
class _Excpt>
303 void _ZYPP_RETHROW(
const _Excpt & excpt_r,
const exception_detail::CodeLocation & where_r ) __attribute__((noreturn));
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