refactor(logging): replace log_err! with structured logging_error! calls

refactor(cm-service): better error handling from Backend to Frontend
This commit is contained in:
Tunglies
2025-03-28 03:39:21 +08:00
parent 59caa22431
commit e8e16f7d57
18 changed files with 232 additions and 128 deletions

View File

@@ -1,8 +1,8 @@
use crate::{
config::{Config, IVerge},
core::backup,
log_err,
utils::dirs::app_home_dir,
logging_error,
utils::{dirs::app_home_dir, logging::Type},
};
use anyhow::Result;
use reqwest_dav::list_cmd::ListFile;
@@ -69,8 +69,9 @@ pub async fn restore_webdav_backup(filename: String) -> Result<()> {
// extract zip file
let mut zip = zip::ZipArchive::new(fs::File::open(backup_storage_path.clone())?)?;
zip.extract(app_home_dir()?)?;
log_err!(
logging_error!(
Type::Backup,
true,
super::patch_verge(
IVerge {
webdav_url,

View File

@@ -1,9 +1,9 @@
use crate::{
config::Config,
core::{handle, tray, CoreManager},
log_err,
logging_error,
module::mihomo::MihomoManager,
utils::resolve,
utils::{logging::Type, resolve},
};
use serde_yaml::{Mapping, Value};
use tauri::Manager;
@@ -28,7 +28,7 @@ pub fn restart_clash_core() {
pub fn restart_app() {
tauri::async_runtime::spawn_blocking(|| {
tauri::async_runtime::block_on(async {
log_err!(CoreManager::global().stop_core().await);
logging_error!(Type::Core, true, CoreManager::global().stop_core().await);
});
resolve::resolve_reset();
let app_handle = handle::Handle::global().app_handle().unwrap();
@@ -54,8 +54,8 @@ pub fn change_clash_mode(mode: String) {
if Config::clash().data().save_config().is_ok() {
handle::Handle::refresh_clash();
log_err!(tray::Tray::global().update_menu());
log_err!(tray::Tray::global().update_icon(None));
logging_error!(Type::Tray, true, tray::Tray::global().update_menu());
logging_error!(Type::Tray, true, tray::Tray::global().update_icon(None));
}
}
Err(err) => println!("{err}"),

View File

@@ -1,8 +1,9 @@
use crate::{
config::{Config, IVerge},
core::{handle, hotkey, sysopt, tray, CoreManager},
log_err,
logging_error,
module::lightweight,
utils::logging::Type,
};
use anyhow::Result;
use serde_yaml::Mapping;
@@ -18,8 +19,8 @@ pub async fn patch_clash(patch: Mapping) -> Result<()> {
CoreManager::global().restart_core().await?;
} else {
if patch.get("mode").is_some() {
log_err!(tray::Tray::global().update_menu());
log_err!(tray::Tray::global().update_icon(None));
logging_error!(Type::Tray, true, tray::Tray::global().update_menu());
logging_error!(Type::Tray, true, tray::Tray::global().update_icon(None));
}
Config::runtime().latest().patch_config(patch);
CoreManager::global().update_config().await?;