libzypp  17.32.4
ztui::Out::Error Class Reference

Convenience class Error reporting. More...

#include <zypp-tui/output/Out.h>

Public Member Functions

 Error (int exitcode_r)
 
 Error (int exitcode_r, std::string msg_r, std::string hint_r=std::string())
 
 Error (int exitcode_r, const zypp::Exception &ex_r, std::string hint_r=std::string())
 
 Error (int exitcode_r, std::string msg_r, const zypp::Exception &ex_r, std::string hint_r=std::string())
 
int report (Application &app_r) const
 Default way of processing a caught Error exception. More...
 

Public Attributes

int _exitcode
 
std::string _msg
 
std::string _hint
 

Static Private Member Functions

static std::string combine (std::string &&msg_r, const zypp::Exception &ex_r)
 
static std::string combine (const zypp::Exception &ex_r)
 

Detailed Description

Convenience class Error reporting.

Called action methods may throw this as exception. The calling function should catch and process it (e.g. by calling report).

This allows e.g. active Out::ProgressBar objects to close properly before the error message is displayed.

try {
Out::ProgressBar report( zypper_r.out(), _("Scanning download directory") );
report->range( todolist.size() );
// now report will indicate an error id closed before reaching 100%
....
if ( some error )
throw( Out::Error( ZYPPER_EXIT_ERR_BUG,
_("Failed to read download directory"),
Errno().asString() ) );
}
catch ( const SourceDownloadImpl::Error & error_r )
{
// Default way of processing a caught Error exception:
// - Write error message and optional hint to screen.
// - Set the ZYPPER_EXIT_ code if necessary.
// - Return the current ZYPPER_EXIT_ code.
return error_r.report( zypper_r );
}

Definition at line 1151 of file Out.h.

Constructor & Destructor Documentation

◆ Error() [1/4]

ztui::Out::Error::Error ( int  exitcode_r)
inline

Definition at line 1153 of file Out.h.

◆ Error() [2/4]

ztui::Out::Error::Error ( int  exitcode_r,
std::string  msg_r,
std::string  hint_r = std::string() 
)
inline

Definition at line 1157 of file Out.h.

◆ Error() [3/4]

ztui::Out::Error::Error ( int  exitcode_r,
const zypp::Exception ex_r,
std::string  hint_r = std::string() 
)
inline

Definition at line 1161 of file Out.h.

◆ Error() [4/4]

ztui::Out::Error::Error ( int  exitcode_r,
std::string  msg_r,
const zypp::Exception ex_r,
std::string  hint_r = std::string() 
)
inline

Definition at line 1165 of file Out.h.

Member Function Documentation

◆ report()

int ztui::Out::Error::report ( Application app_r) const

Default way of processing a caught Error exception.

  • Write error message and optional hint to screen.
  • Set the ZYPPER_EXIT_ code if necessary.
    Returns
    the zypper exitcode.

Definition at line 144 of file Out.cc.

◆ combine() [1/2]

std::string ztui::Out::Error::combine ( std::string &&  msg_r,
const zypp::Exception ex_r 
)
staticprivate

Definition at line 153 of file Out.cc.

◆ combine() [2/2]

std::string ztui::Out::Error::combine ( const zypp::Exception ex_r)
staticprivate

Definition at line 166 of file Out.cc.

Member Data Documentation

◆ _exitcode

int ztui::Out::Error::_exitcode

Definition at line 1175 of file Out.h.

◆ _msg

std::string ztui::Out::Error::_msg

Definition at line 1176 of file Out.h.

◆ _hint

std::string ztui::Out::Error::_hint

Definition at line 1177 of file Out.h.


The documentation for this class was generated from the following files: