1 /*---------------------------------------------------------------------\
3 | |__ / \ / / . \ . \ |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/base/UserRequestException.h
12 #ifndef ZYPP_BASE_USERREQUESTEXCEPTION_H
13 #define ZYPP_BASE_USERREQUESTEXCEPTION_H
17 #include "zypp/base/Exception.h"
19 ///////////////////////////////////////////////////////////////////
21 { /////////////////////////////////////////////////////////////////
23 ///////////////////////////////////////////////////////////////////
25 // CLASS NAME : UserRequestException
27 /** Base for exceptions caused by explicit user request.
29 * Use the derived convenience classes to throw exceptions
32 * ProgressData ticks( makeProgressData( input_r ) );
33 * ticks.sendTo( fnc_r );
34 * ticks.toMin(); // start sending min (0)
36 * iostr::EachLine line( input_r );
37 * for( ; line; line.next() )
41 * if ( ! ticks.set( input_r.stream().tellg() ) )
42 * ZYPP_THROW( AbortRequestException( "" ) );
47 * catch ( const AbortRequestException & excpt_r )
53 * catch ( const UserRequestException & excpt_r )
55 * switch ( excpt_r.kind() )
57 * case UserRequestException::ABORT:
64 class UserRequestException : public Exception
67 enum Kind { UNSPECIFIED, IGNORE, SKIP, RETRY, ABORT };
70 UserRequestException( const std::string & msg_r = std::string() );
71 UserRequestException( const std::string & msg_r, const Exception & history_r );
73 UserRequestException( Kind kind_r, const std::string & msg_r = std::string() );
74 UserRequestException( Kind kind_r, const std::string & msg_r, const Exception & history_r );
79 virtual std::ostream & dumpOn( std::ostream & str ) const;
83 ///////////////////////////////////////////////////////////////////
85 /** Convenience macro to declare more specific PluginScriptExceptions. */
86 #define declException( EXCP, KIND ) \
87 struct EXCP : public UserRequestException { \
89 EXCP( const std::string & msg_r = std::string() ) \
90 : UserRequestException( KIND, msg_r ) \
92 EXCP( const std::string & msg_r, const Exception & history_r ) \
93 : UserRequestException( KIND, msg_r, history_r ) \
97 declException( IgnoreRequestException, IGNORE );
98 declException( SkipRequestException, SKIP );
99 declException( RetryRequestException, RETRY );
100 declException( AbortRequestException, ABORT );
104 /////////////////////////////////////////////////////////////////
106 ///////////////////////////////////////////////////////////////////
107 #endif // ZYPP_BASE_USERREQUESTEXCEPTION_H