mirror of
https://github.com/modrinth/code.git
synced 2026-08-31 03:55:59 +00:00
* feat: implement instance share page + search_users backend call * feat: invite players modal * feat: use tanstack queries for friends sync across app pages * feat: base shared instances implementation * fix: admon style * feat: impl instance admonitions like server panel * fix: impl get + del usage * feat: support modpack links * feat: invite notif accepting * fix: lint + fmt * feat: impl install to play * feat: impl usage of UpdateToPlayModal * feat: warnings on deleting/disabling shared-instance version content * fix: send instance name * feat: align with backend * feat: shared instances qa * feat: wrong account protection * feat: qa * fix: smartly apply updates * fix: install bug * fix: 401/404 differentiation * fix: fmt+prepr * feat: qa * feat: qa * fix: signing out messes up revoke/deleted checks * feat: qa * fix: fmt + lint * feat: lock content if part of shared instance * fix: lint * [do not merge] feat: rough invite links impl temp (#6666) * fix: wrong cmd * feat: invite page * fix: server-manager DTO mismatch * fix: drop anonymous invite link acceptance * refactor: structured shared-instance unavailable errors * refactor: centralise error presentations * refactor: dedupe shared instance diff detection * fix: logging in reqwests * refactor: move app.vue shared instances into handler * refactor: break up Share.vue * refactor: split up shared instances state outside of instance index * refactor: dedicated shared instances install/update modals + split up page * refactor: centralized managed content * refactor: split up install shared to own runner + shared.rs split up * refactor: dedupe sql for instance metadata enrichmnt * refactor: friends composable + dedupe friends logic across usages * chore: reduced unused code * fix: align with backend * fix: lint * fix: file sha changes * fix: invite links not working due to icon signed * feat: qa * feat: reporting frontend dummy * fix: try use header * remove: file hash field * fix: pin box * feat: malware warning for shared instances * fix: cache rule * feat: config files syncing * feat: disable config sharing * fix: header * fix: use mark ready * fix: dont cause push update for configs * fix: lint * feat: sharing page in settings * feat: move config + change flow * fix: qa * fix: lint prepr * feat: proxy file upload thru shared instances backend * fix: use collapisible * fix: push config * fix: config * feat: swap out sign in modal for new one * fix: report flow * fix: exclude configs.zip from external warnings * fix: nuxi init * fix: config bundle downloading * fix: error notif * fix: polling * fix: qa * fix: lint + prepr * feat: shared instances moderation frontend + hook up report flow * fix: report copy * fix: lint * fix: lint * fix: modrinth ids being undefined * feat: instance quarantining * fix: prepr + fmt * fix: quarantined -> locked terminology * fix: missing endpoint impls + fmt * fix: missing api in build.rs * fix: share tab jittery * fix: fmt *PT bug * fix: invites count as users even if pending * fix: prepr * fix: invite page owner in users list * fix: lint * fix: qa * fix: lint * fix: members stale not clearing * fix: invite use joined_at field * fix: lint * fix: qa --------- Co-authored-by: sychic <47618543+Sychic@users.noreply.github.com>
134 lines
4.2 KiB
Rust
134 lines
4.2 KiB
Rust
use serde::ser::SerializeStruct;
|
|
use serde::{Serialize, Serializer};
|
|
use thiserror::Error;
|
|
|
|
pub mod auth;
|
|
pub mod import;
|
|
pub mod install;
|
|
pub mod instance;
|
|
pub mod jre;
|
|
pub mod logs;
|
|
pub mod metadata;
|
|
pub mod minecraft_skins;
|
|
pub mod mr_auth;
|
|
pub mod process;
|
|
pub mod reports;
|
|
pub mod settings;
|
|
pub mod shortcuts;
|
|
pub mod tags;
|
|
pub mod users;
|
|
pub mod utils;
|
|
|
|
pub mod ads;
|
|
#[cfg(target_os = "macos")]
|
|
mod ads_occlusion_macos;
|
|
#[cfg(windows)]
|
|
mod ads_occlusion_windows;
|
|
pub mod cache;
|
|
pub mod files;
|
|
pub mod friends;
|
|
pub mod worlds;
|
|
|
|
mod oauth_utils;
|
|
|
|
pub type Result<T> = std::result::Result<T, TheseusSerializableError>;
|
|
|
|
// // Main returnable Theseus GUI error
|
|
// // Needs to be Serializable to be returned to the JavaScript side
|
|
// #[derive(Error, Debug, Serialize)]
|
|
// pub enum TheseusGuiError {
|
|
// #[error(transparent)]
|
|
// Serializable(),
|
|
// }
|
|
|
|
// Serializable error intermediary, so TheseusGuiError can be Serializable (eg: so that we can return theseus::Errors in Tauri directly)
|
|
#[derive(Error, Debug)]
|
|
pub enum TheseusSerializableError {
|
|
#[error("{0}")]
|
|
Theseus(#[from] theseus::Error),
|
|
|
|
#[error("IO error: {0}")]
|
|
IO(#[from] std::io::Error),
|
|
|
|
#[error("Tauri error: {0}")]
|
|
Tauri(#[from] tauri::Error),
|
|
|
|
#[cfg(feature = "updater")]
|
|
#[error("Updater error: {0}")]
|
|
Updater(#[from] tauri_plugin_updater::Error),
|
|
|
|
#[cfg(feature = "updater")]
|
|
#[error("HTTP error: {0}")]
|
|
Http(#[from] tauri_plugin_http::reqwest::Error),
|
|
}
|
|
|
|
// Generic implementation of From<T> for ErrorTypeA
|
|
// impl<T> From<T> for TheseusGuiError
|
|
// where
|
|
// TheseusSerializableError: From<T>,
|
|
// {
|
|
// fn from(error: T) -> Self {
|
|
// TheseusGuiError::Serializable(TheseusSerializableError::from(error))
|
|
// }
|
|
// }
|
|
|
|
// This is a very simple macro that implements a very basic Serializable for each variant of TheseusSerializableError,
|
|
// where the field is the string. (This allows easy extension to errors without many match arms)
|
|
macro_rules! impl_serialize {
|
|
($($variant:ident),* $(,)?) => {
|
|
impl Serialize for TheseusSerializableError {
|
|
fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
|
|
where
|
|
S: Serializer,
|
|
{
|
|
match self {
|
|
// For the Theseus variant, we add a special display for the error,
|
|
// to view the spans if subscribed to them (which is information that is lost when serializing)
|
|
TheseusSerializableError::Theseus(theseus_error) => {
|
|
$crate::error::display_tracing_error(theseus_error);
|
|
|
|
let unavailable_reason = match theseus_error.raw.as_ref() {
|
|
theseus::ErrorKind::SharedInstanceUnavailable(reason) => Some(reason),
|
|
_ => None,
|
|
};
|
|
let mut state = serializer.serialize_struct(
|
|
"Theseus",
|
|
if unavailable_reason.is_some() { 4 } else { 2 },
|
|
)?;
|
|
state.serialize_field("field_name", "Theseus")?;
|
|
state.serialize_field("message", &theseus_error.to_string())?;
|
|
if let Some(reason) = unavailable_reason {
|
|
state.serialize_field("code", "shared_instance_unavailable")?;
|
|
state.serialize_field("reason", reason)?;
|
|
}
|
|
state.end()
|
|
}
|
|
$(
|
|
TheseusSerializableError::$variant(message) => {
|
|
let mut state = serializer.serialize_struct(stringify!($variant), 2)?;
|
|
state.serialize_field("field_name", stringify!($variant))?;
|
|
state.serialize_field("message", &message.to_string())?;
|
|
state.end()
|
|
},
|
|
)*
|
|
}
|
|
}
|
|
}
|
|
};
|
|
}
|
|
|
|
// Use the macro to implement Serialize for TheseusSerializableError
|
|
#[cfg(not(feature = "updater"))]
|
|
impl_serialize! {
|
|
IO,
|
|
Tauri,
|
|
}
|
|
|
|
#[cfg(feature = "updater")]
|
|
impl_serialize! {
|
|
IO,
|
|
Tauri,
|
|
Updater,
|
|
Http,
|
|
}
|