Skip to content

Commit

Permalink
QSocCliWorker: Add the real showError function
Browse files Browse the repository at this point in the history
- Added the `showError` function to handle displaying error messages and
  setting the exit code without showing help text.
- Modified documentation comments to reflect the addition and purpose of the
  `showError` function.

Signed-off-by: Huang Rui <[email protected]>
  • Loading branch information
vowstar committed Jul 20, 2024
1 parent 5b68408 commit 59866bc
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/cli/qsoccliworker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@ bool QSocCliWorker::showErrorWithHelp(int exitCode, const QString &message)
return false;
}

bool QSocCliWorker::showError(int exitCode, const QString &message)
{
qCritical().noquote() << message;
this->exitCode = exitCode;
return false;
}

bool QSocCliWorker::showInfo(int exitCode, const QString &message)
{
qInfo().noquote() << message;
Expand Down
10 changes: 10 additions & 0 deletions src/cli/qsoccliworker.h
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,16 @@ public slots:
*/
bool showErrorWithHelp(int exitCode, const QString &message);

/**
* @brief Show error message and emit exit with exitCode.
* @details This function will show error message and emit exit with
* exitCode.
* @param exitCode The exit code to emit.
* @param message The error message to show.
* @return bool always false.
*/
bool showError(int exitCode, const QString &message);

/**
* @brief Show info message and emit exit with exitCode.
* @details This function will show info message and emit exit with
Expand Down

0 comments on commit 59866bc

Please sign in to comment.