2026-07-11 01:19:36 +08:00
|
|
|
from pathlib import Path
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class LauncherException(Exception):
|
2026-07-12 22:43:34 +08:00
|
|
|
user_message = "Launcher error occurred."
|
2026-07-11 01:19:36 +08:00
|
|
|
|
2026-07-12 22:43:34 +08:00
|
|
|
def __init__(self, message=None, *, user_message=None):
|
|
|
|
|
super().__init__(message or user_message or self.user_message)
|
|
|
|
|
if user_message is not None:
|
|
|
|
|
self.user_message = user_message
|
2026-07-11 01:19:36 +08:00
|
|
|
|
|
|
|
|
class HashMismatchException(Exception):
|
|
|
|
|
def __init__(self, hash_name, got_hash, expected_hash, filepath: str | Path):
|
|
|
|
|
if type(filepath) == Path: filepath = Path(filepath).absolute().as_posix()
|
|
|
|
|
self.message = "File {} hash mismatch. Expected hash {}. Got hash {} ({})".format(filepath, got_hash,
|
|
|
|
|
expected_hash, hash_name)
|
2026-07-12 22:43:34 +08:00
|
|
|
super().__init__(self.message)
|
|
|
|
|
|
|
|
|
|
class UnsupportedPlatformException(LauncherException):
|
|
|
|
|
user_message = "Current platform or architecture is not supported."
|
|
|
|
|
|
|
|
|
|
class VersionNotSelectedException(LauncherException):
|
|
|
|
|
user_message = "Select a version before continuing."
|
|
|
|
|
|
|
|
|
|
class VersionManifestFetchException(LauncherException):
|
|
|
|
|
user_message = "Unable to fetch version manifest."
|
|
|
|
|
|
|
|
|
|
class VersionManifestSaveException(LauncherException):
|
|
|
|
|
user_message = "Unable to save version manifest."
|
|
|
|
|
|
|
|
|
|
class NoVersionFoundException(LauncherException):
|
|
|
|
|
user_message = "No version found. (This should never happen)"
|
|
|
|
|
|
|
|
|
|
class NoSpecifiedVersionKeyException(LauncherException):
|
|
|
|
|
user_message = "Specified version or type not found."
|
|
|
|
|
|
|
|
|
|
class VersionDataKeyNotFoundException(LauncherException):
|
|
|
|
|
user_message = "Specified version data section (key) not found."
|
|
|
|
|
|
|
|
|
|
class VersionManifestException(LauncherException):
|
|
|
|
|
user_message = "Unable to load version manifest."
|
|
|
|
|
|
|
|
|
|
class DependencyException(LauncherException):
|
|
|
|
|
user_message = "Unable to find dependency."
|
|
|
|
|
|
|
|
|
|
class NativeResolveException(LauncherException):
|
|
|
|
|
user_message = "Unable to resolve native libraries."
|
|
|
|
|
|
|
|
|
|
class DownloadException(LauncherException):
|
|
|
|
|
user_message = "Some files failed to download."
|
|
|
|
|
|
|
|
|
|
class ExtractException(LauncherException):
|
|
|
|
|
user_message = "Unable to extract native libraries."
|
|
|
|
|
|
2026-07-13 00:03:51 +08:00
|
|
|
class AssetManifestFetchException(LauncherException):
|
|
|
|
|
user_message = "Unable to fetch asset manifest."
|
|
|
|
|
|
|
|
|
|
class AssetManifestSaveException(LauncherException):
|
|
|
|
|
user_message = "Unable to save asset manifest."
|
|
|
|
|
|
|
|
|
|
class AssetManifestException(LauncherException):
|
|
|
|
|
user_message = "Unable to load asset manifest."
|
|
|
|
|
|
|
|
|
|
class AssetDataKeyNotFoundException(LauncherException):
|
|
|
|
|
user_message = "Specified asset data section (key) not found."
|