libzypp: ztui::Out::Error Class Reference

libzypp 17.36.6

Public Member Functions | Public Attributes | Static Private Member Functions | List of all members
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.

## 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 );
}
ztui::Out::ProgressBar
Convenience class for progress output.
Definition Out.h:983
ztui::Out::error
virtual void error(const std::string &problem_desc, const std::string &hint="")=0
Show an error message and an optional hint.
zypp::Errno
Convenience errno wrapper.
Definition Errno.h:26
zypp::asString
std::string asString(const Patch::Category &obj)
Definition Patch.cc:122
ztui::Out::Error
Convenience class Error reporting.
Definition Out.h:1146
ztui::Out::Error::report
int report(Application &app_r) const
Default way of processing a caught Error exception.
Definition Out.cc:155
_
#define _(MSG)
Definition Gettext.h:39

Definition at line 1145 of file Out.h.

## Constructor & Destructor Documentation

## ◆ Error() [1/4]

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

Definition at line 1147 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 1151 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 1155 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 1159 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 155 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 164 of file Out.cc.

## ◆ combine() [2/2]

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

Definition at line 177 of file Out.cc.

## Member Data Documentation

## ◆ _exitcode

int ztui::Out::Error::_exitcode

Definition at line 1169 of file Out.h.

## ◆ _msg

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

Definition at line 1170 of file Out.h.

## ◆ _hint

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

Definition at line 1171 of file Out.h.

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

- zypp-tui/output/Out.h
- zypp-tui/output/Out.cc