OneLauncher-Cracked/packages/oneclient_mc/src/error.rs
Maciek 0ab544f265
feat: custom cluster instances (#859)
* feat: added adding new instances of a cluster with 'start from scratch' option enabling user to create a vanilla/modded cluster; fixed couple pre-existing bugs that wouldn't let other loaders boot up

* feat: fully implemented cluster creation modal design

* chore: refactoring

* feat: expanded the tags section on customization step; found that fabric doesnt work with 1.8.9

* feat: added gallery covers handling for new cluster instances

* feat: added 'redirecting' from fabric to orinthe on versions pre-1.14

* feat: added java-version-override

* feat: added loader types migrations (right now they dont migrate mods because there are no bundles)

* chore: wider loader dropdown for multiloader cluster (if it will be used in the future)

* chore: fixed more issues with isolated and shared dir, with migrations and instances naming

* chore: refactor; taken the loader version dropdown from version picker view back to loader selector

* chore: deleted Quilt from UI

---------

Co-authored-by: LynithDev <61880709+LynithDev@users.noreply.github.com>
2026-09-29 19:08:21 +02:00

94 lines
2.8 KiB
Rust

use oneclient_common::domain::GameLoader;
use thiserror::Error;
pub type McResult<T> = Result<T, McError>;
#[derive(Debug, Error)]
pub enum McError {
#[error("no client download exists for version {0}")]
NoClientDownload(String),
#[error("failed to resolve library artifact path for {0}")]
LibraryPath(String),
#[error(
"library {library} is missing from the install; the game cannot start without it (expected at {path})"
)]
MissingLibrary { library: String, path: String },
#[error("invalid game version {0}")]
InvalidVersion(String),
#[error("failed to fetch metadata")]
FetchError,
#[error("loader {0} does not use a modded manifest")]
NotModdedManifest(GameLoader),
#[error("loader {0} does not use a vanilla manifest")]
NotVanillaManifest(GameLoader),
#[error("no matching loader found")]
NoMatchingLoader,
#[error("requested loader version '{requested}' was not found")]
RequestedLoaderVersionNotFound { requested: String },
#[error("{loader} has no build for Minecraft {version}")]
NoMatchingVersion { loader: GameLoader, version: String },
#[error(
"{version} ships no native libraries for {platform}; this platform is not supported \
by this version"
)]
NoNativesForPlatform { version: String, platform: String },
#[error("cancelled: {failed} file(s) could not be downloaded")]
IncompleteInstallCancelled { failed: usize },
/// A Mojang response was well-formed JSON but not what the API documents
#[error("minecraft: {0}")]
Minecraft(String),
#[error("failed to parse metadata: {0}")]
ParseError(#[from] serde_json::Error),
#[error(transparent)]
Request(#[from] oneclient_net::RequestError),
#[error(transparent)]
Io(#[from] polyio::IOError),
#[error(transparent)]
StdIo(#[from] std::io::Error),
#[error(transparent)]
Paths(#[from] oneclient_common::PathsError),
#[error("Invalid URL: {0}")]
Url(#[from] url::ParseError),
}
impl McError {
/// Environment fault rather than a launcher bug drives Sentry policy upstream
#[must_use]
pub fn is_transient(&self) -> bool {
match self {
Self::Request(source) => source.is_transient(),
Self::Io(polyio::IOError::IOError(source))
| Self::Io(polyio::IOError::PathIOError { source, .. })
| Self::StdIo(source) => {
use std::io::ErrorKind;
matches!(
source.kind(),
ErrorKind::ConnectionRefused
| ErrorKind::ConnectionReset
| ErrorKind::ConnectionAborted
| ErrorKind::NotConnected
| ErrorKind::TimedOut
)
}
_ => false,
}
}
}