Skip to content

Commit

Permalink
Add support for non-critical installation errors
Browse files Browse the repository at this point in the history
The OSCAP add-on needs to be able to raise a non-critical installation error.
In that case, the users should be allowed to continue with the installation
if they want to.
  • Loading branch information
poncovka committed Feb 4, 2021
1 parent a4c0076 commit f1ce918
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
15 changes: 14 additions & 1 deletion pyanaconda/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from pyanaconda.core.i18n import _, C_
from pyanaconda.flags import flags
from pyanaconda.modules.common.errors.installation import BootloaderInstallationError, \
StorageInstallationError
StorageInstallationError, NonCriticalInstallationError
from pyanaconda.modules.common.errors.payload import SourceSetupError
from pyanaconda.modules.common.errors.storage import UnusableStorageError
from pyanaconda.payload.errors import PayloadInstallError, DependencyError, PayloadSetupError
Expand Down Expand Up @@ -110,6 +110,9 @@ def _get_default_mapping(self):
# Payload DBus errors
SourceSetupError.__name__: self._payload_setup_handler,

# General installation errors.
NonCriticalInstallationError.__name__: self._non_critical_error_handler,

# DNF errors
"MarkingErrors": self._install_specs_handler,
}
Expand Down Expand Up @@ -205,6 +208,16 @@ def _bootloader_error_handler(self, exn):
else:
return ERROR_RAISE

def _non_critical_error_handler(self, exn):
message = _("The following error occurred during the installation:"
"\n\n{details}\n\nWould you like to ignore this and "
"continue with installation?").format(details=str(exn))

if self.ui.showYesNoQuestion(message):
return ERROR_CONTINUE
else:
return ERROR_RAISE

def cb(self, exn):
"""This method is the callback that all error handling should pass
through. The return value is one of the ERROR_* constants defined
Expand Down
6 changes: 6 additions & 0 deletions pyanaconda/modules/common/errors/installation.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ class InstallationError(AnacondaError):
pass


@dbus_error("NonCriticalInstallationError", namespace=ANACONDA_NAMESPACE)
class NonCriticalInstallationError(AnacondaError):
"""Exception for the non-critical installation errors."""
pass


@dbus_error("LanguageInstallationError", namespace=ANACONDA_NAMESPACE)
class LanguageInstallationError(InstallationError):
"""Exception for the language installation errors."""
Expand Down

0 comments on commit f1ce918

Please sign in to comment.