Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add OutdatedPatchDependency exception #557

Merged
merged 2 commits into from
Dec 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file.
27 changes: 27 additions & 0 deletions skytemple_files/common/exceptions/outdated_patch_dependency.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from skytemple_files.common.i18n_util import _


class OutdatedPatchDependencyError(Exception):
"""
Raised when trying to apply an ASM patch that depends on another patches that exist but are outdated
"""

def __init__(self, patch_name: str, outdated_dependencies: list[str]):
"""
Creates a new OutdatedPatchDependencyError
:param patch_name: Name of the patch that failed to apply due to outdated dependencies
:param outdated_dependencies: List containing the names of each outdated dependency
"""
self.patch_name = patch_name
self.outdated_dependencies = outdated_dependencies

def __str__(self):
msg = _(
f"The patch {self.patch_name} cannot be applied because the following patches it depends on "
f"are outdated:"
)
for dependency in self.outdated_dependencies:
msg += f"\n- {dependency}"
msg += _("Please reapply these patches first.")

return msg
2 changes: 2 additions & 0 deletions skytemple_files/patch/handler/abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ def apply(self, apply: Callable[[], None], rom: NintendoDSRom, config: Pmd2Data)

:raises RuntimeError: On error applying the patch. If this is raised, the ROM will not be modified.
:raises ValueError: On error applying the patch. If this is raised, the ROM will not be modified.
:raises OutdatedPatchDependencyError: If one of the patches this patch depends on is applied but outdated.
The user will be prompted to reapply it first, and the ROM will not be modified.
"""

@abstractmethod
Expand Down
Loading