From ec758ea3dcf727cddd360ba4af8e0ef57e3cd123 Mon Sep 17 00:00:00 2001 From: eythaann Date: Wed, 9 Oct 2024 11:09:06 -0500 Subject: [PATCH] enh(errors): improve logs of errors to easier debug on prod --- Cargo.lock | 60 +------- Cargo.toml | 10 +- src/background/error_handler.rs | 121 +++++++++------- src/background/hook.rs | 14 +- src/background/instance.rs | 3 +- src/background/main.rs | 13 +- src/background/modules/cli/application/mod.rs | 4 +- .../modules/power/infrastructure.rs | 4 +- src/background/plugins.rs | 135 ++++++++++-------- src/background/seelen_weg/icon_extractor.rs | 13 +- src/background/system/brightness.rs | 126 ++++++++-------- src/background/windows_api/mod.rs | 13 +- tauri.conf.json | 34 +++-- 13 files changed, 276 insertions(+), 274 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 36a94611..3c2021f2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -856,33 +856,6 @@ dependencies = [ "objc", ] -[[package]] -name = "color-eyre" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55146f5e46f237f7423d74111267d4597b59b0dad0ffaf7303bce9945d843ad5" -dependencies = [ - "backtrace", - "color-spantrace", - "eyre", - "indenter", - "once_cell", - "owo-colors", - "tracing-error", -] - -[[package]] -name = "color-spantrace" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd6be1b2a7e382e2b98b43b2adcca6bb0e465af0bdd38123873ae61eb17a72c2" -dependencies = [ - "once_cell", - "owo-colors", - "tracing-core", - "tracing-error", -] - [[package]] name = "color_quant" version = "1.1.0" @@ -1526,16 +1499,6 @@ dependencies = [ "zune-inflate", ] -[[package]] -name = "eyre" -version = "0.6.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cd915d99f24784cdc19fd37ef22b97e3ff0ae756c7e492e9fbfe897d61e2aec" -dependencies = [ - "indenter", - "once_cell", -] - [[package]] name = "fastrand" version = "2.1.0" @@ -2390,12 +2353,6 @@ version = "1.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "44feda355f4159a7c757171a77de25daf6411e217b4cabd03bd6650690468126" -[[package]] -name = "indenter" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683" - [[package]] name = "indexmap" version = "1.9.3" @@ -3392,9 +3349,9 @@ checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" [[package]] name = "owo-colors" -version = "3.5.0" +version = "4.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1b04fb49957986fdce4d6ee7a65027d55d4b6d2265e5848bbb507b58ccfdb6f" +checksum = "fb37767f6569cd834a413442455e0f066d0d522de8630436e2a1761d9726ba56" [[package]] name = "pango" @@ -4474,10 +4431,10 @@ name = "seelen-ui" version = "2.0.0-beta.16" dependencies = [ "arc-swap", + "backtrace", "base64 0.22.1", "battery", "clap", - "color-eyre", "crossbeam-channel", "encoding_rs", "evalexpr", @@ -4488,6 +4445,7 @@ dependencies = [ "log", "notify-debouncer-full", "os_info", + "owo-colors", "parking_lot", "phf 0.11.2", "quick-xml 0.36.2", @@ -5820,16 +5778,6 @@ dependencies = [ "valuable", ] -[[package]] -name = "tracing-error" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d686ec1c0f384b1277f097b2f279a2ecc11afe8c133c1aabf036a27cb4cd206e" -dependencies = [ - "tracing", - "tracing-subscriber", -] - [[package]] name = "tracing-log" version = "0.2.0" diff --git a/Cargo.toml b/Cargo.toml index 7516050b..3d85d2a0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,6 +20,13 @@ path = "src/background/main.rs" incremental = true rustflags = ["-Z", "threads=8"] +[profile.release] +debug = 1 +opt-level = "z" +lto = true +codegen-units = 1 +rustflags = ["-Z", "threads=8"] + [build-dependencies] tauri-build = { version = "2.0.0-rc", features = [] } @@ -42,7 +49,6 @@ tauri-plugin-http = "2.0.0-rc" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" serde_yaml = "0.9.34" -color-eyre = "0.6.2" lazy_static = "1.4.0" parking_lot = "0.12.1" log = "0.4" @@ -68,6 +74,8 @@ notify-debouncer-full = "0.3.1" encoding_rs = "0.8.34" evalexpr = "=11.3.0" quick-xml = { version = "0.36.2", features = ["serialize", "encoding"] } +backtrace = "0.3.71" +owo-colors = "4.1.0" [dependencies.windows] version = "=0.58.0" diff --git a/src/background/error_handler.rs b/src/background/error_handler.rs index 8f362225..53cf4e5d 100644 --- a/src/background/error_handler.rs +++ b/src/background/error_handler.rs @@ -2,29 +2,38 @@ macro_rules! define_app_errors { ($( $variant:ident($error_type:ty); )*) => { - #[derive(Debug)] - pub enum AppError { - $( - $variant($error_type), - )* - } - $( impl From<$error_type> for AppError { fn from(err: $error_type) -> Self { - AppError::$variant(err) + let backtrace = backtrace::Backtrace::new(); + AppError { msg: format!("{}({:?})", stringify!($variant), err), backtrace } } } )* }; } +#[macro_export] +macro_rules! log_error { + ($($result:expr),*) => { + $( + if let Err(err) = $result { + log::error!("{:?}", err); + } + )* + }; +} + +pub struct AppError { + msg: String, + backtrace: backtrace::Backtrace, +} + define_app_errors!( - Seelen(String); + Custom(String); Io(std::io::Error); Tauri(tauri::Error); TauriShell(tauri_plugin_shell::Error); - Eyre(color_eyre::eyre::Error); Windows(windows::core::Error); SerdeJson(serde_json::Error); SerdeYaml(serde_yaml::Error); @@ -44,9 +53,52 @@ define_app_errors!( EvalExpr(evalexpr::EvalexprError); ); -impl From<&str> for AppError { - fn from(err: &str) -> Self { - AppError::Seelen(err.to_owned()) +impl std::fmt::Debug for AppError { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{}", self.msg)?; + + let frames = self.backtrace.frames(); + if !frames.is_empty() { + writeln!(f)?; + } + + let mut index = 0; + for frame in frames { + for symbol in frame.symbols() { + let name = match symbol.name() { + Some(name) => name.to_string(), + None => continue, + }; + + // skip backtrace traces + if name.starts_with("backtrace") { + continue; + } + + // 2) skip trace of other modules/libraries specially tracing of tao and tauri libs + if !name.starts_with("seelen_ui") { + index += 1; + continue; + } + + writeln!(f, " {}: {}", index, name)?; + if let Some(file) = symbol.filename() { + write!(f, " at: \"{}", file.to_string_lossy())?; + if let Some(line) = symbol.lineno() { + write!(f, ":{}", line)?; + if let Some(col) = symbol.colno() { + write!(f, ":{}", col)?; + } + } + writeln!(f, "\"")?; + } else { + writeln!(f, " at: ")? + } + + index += 1; + } + } + Ok(()) } } @@ -56,6 +108,12 @@ impl std::fmt::Display for AppError { } } +impl From<&str> for AppError { + fn from(err: &str) -> Self { + err.to_owned().into() + } +} + // needed to tauri::command macro (exposed functions to frontend) impl From for tauri::ipc::InvokeError { fn from(val: AppError) -> Self { @@ -63,12 +121,6 @@ impl From for tauri::ipc::InvokeError { } } -impl From for String { - fn from(err: AppError) -> String { - format!("{}", err) - } -} - impl From for AppError { fn from(output: tauri_plugin_shell::process::Output) -> Self { if !output.stderr.is_empty() { @@ -81,33 +133,4 @@ impl From for AppError { } } -impl std::error::Error for AppError { - fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - match self { - AppError::Eyre(err) => Some(err.root_cause()), - AppError::Io(err) => Some(err), - AppError::Tauri(err) => Some(err), - AppError::Windows(err) => Some(err), - AppError::SerdeJson(err) => Some(err), - AppError::Utf8(err) => Some(err), - AppError::Utf16(err) => Some(err), - AppError::CrossbeamRecv(err) => Some(err), - AppError::TauriShell(err) => Some(err), - AppError::TryFromInt(err) => Some(err), - _ => None, - } - } -} - -pub type Result = core::result::Result; - -#[macro_export] -macro_rules! log_error { - ($($result:expr),*) => { - $( - if let Err(err) = $result { - log::error!("{:?}", err); - } - )* - }; -} +pub type Result = core::result::Result; diff --git a/src/background/hook.rs b/src/background/hook.rs index 1aafba45..3d0dcba5 100644 --- a/src/background/hook.rs +++ b/src/background/hook.rs @@ -9,7 +9,6 @@ use std::{ time::{Duration, Instant}, }; -use color_eyre::owo_colors::OwoColorize; use itertools::Itertools; use lazy_static::lazy_static; use parking_lot::Mutex; @@ -114,10 +113,21 @@ impl HookManager { if !LOG_WIN_EVENTS.load(Ordering::Relaxed) || event == WinEvent::ObjectLocationChange { return; } + let event_value = { + #[cfg(dev)] + { + use owo_colors::OwoColorize; + event.green() + } + #[cfg(not(dev))] + { + &event + } + }; log::debug!( "{:?}({:?}) || {} || {} || {}", - event.green(), + event_value, origin.0, WindowsApi::exe(origin).unwrap_or_default(), WindowsApi::get_class(origin).unwrap_or_default(), diff --git a/src/background/instance.rs b/src/background/instance.rs index e7388430..1cd83999 100644 --- a/src/background/instance.rs +++ b/src/background/instance.rs @@ -1,4 +1,3 @@ -use color_eyre::eyre::eyre; use getset::{Getters, MutGetters}; use crate::{ @@ -29,7 +28,7 @@ unsafe impl Send for SeelenInstanceContainer {} impl SeelenInstanceContainer { pub fn new(hmonitor: HMONITOR, settings: &FullState) -> Result { if hmonitor.is_invalid() { - return Err(eyre!("Invalid Monitor").into()); + return Err("Invalid Monitor".into()); } let mut instance = Self { handle: hmonitor, diff --git a/src/background/main.rs b/src/background/main.rs index 86840397..76226ff5 100644 --- a/src/background/main.rs +++ b/src/background/main.rs @@ -22,7 +22,6 @@ mod winevent; use std::io::{BufWriter, Write}; -use color_eyre::owo_colors::OwoColorize; use error_handler::Result; use exposed::register_invoke_handler; use itertools::Itertools; @@ -44,8 +43,8 @@ use utils::PERFORMANCE_HELPER; use windows::Win32::Security::{SE_DEBUG_NAME, SE_SHUTDOWN_NAME}; use windows_api::WindowsApi; -fn register_panic_hook() { - std::panic::set_hook(Box::new(|info| { +fn register_panic_hook() -> Result<()> { + std::panic::set_hook(Box::new(move |info| { let cause = info .payload() .downcast_ref::() @@ -69,10 +68,11 @@ fn register_panic_hook() { log::error!( "A panic occurred:\n Cause: {}\n Location: {}", - cause.cyan(), - string_location.purple() + cause, + string_location ); })); + Ok(()) } fn print_initial_information() { @@ -162,8 +162,7 @@ fn is_already_runnning() -> bool { } fn main() -> Result<()> { - register_panic_hook(); - color_eyre::install()?; + register_panic_hook()?; trace_lock!(PERFORMANCE_HELPER).start("setup"); let command = trace_lock!(SEELEN_COMMAND_LINE).clone(); diff --git a/src/background/modules/cli/application/mod.rs b/src/background/modules/cli/application/mod.rs index 4b4ce62d..1dd4dbe6 100644 --- a/src/background/modules/cli/application/mod.rs +++ b/src/background/modules/cli/application/mod.rs @@ -67,10 +67,10 @@ macro_rules! get_subcommands { Ok(SubCommand::$subcommand$(($((sub_matches.get_one(stringify!($arg_name)) as Option<&$arg_type>).unwrap().clone()),*))?) }, )* - _ => Err(color_eyre::eyre::eyre!("Unknown subcommand.").into()), + _ => Err("Unknown subcommand.".into()), } } else { - Err(color_eyre::eyre::eyre!("No subcommand was provided.").into()) + Err("No subcommand was provided.".into()) } } } diff --git a/src/background/modules/power/infrastructure.rs b/src/background/modules/power/infrastructure.rs index 98dfe2ad..9b9236af 100644 --- a/src/background/modules/power/infrastructure.rs +++ b/src/background/modules/power/infrastructure.rs @@ -138,13 +138,13 @@ pub fn suspend() { } #[tauri::command(async)] -pub fn restart() -> Result<(), String> { +pub fn restart() -> Result<()> { WindowsApi::exit_windows(EWX_REBOOT, SHTDN_REASON_NONE)?; Ok(()) } #[tauri::command(async)] -pub fn shutdown() -> Result<(), String> { +pub fn shutdown() -> Result<()> { WindowsApi::exit_windows(EWX_SHUTDOWN, SHTDN_REASON_NONE)?; Ok(()) } diff --git a/src/background/plugins.rs b/src/background/plugins.rs index e87128e1..b045cdc1 100644 --- a/src/background/plugins.rs +++ b/src/background/plugins.rs @@ -1,63 +1,72 @@ -use color_eyre::owo_colors::OwoColorize; -use tauri::{Builder, Wry}; -use tauri_plugin_autostart::MacosLauncher; -use tauri_plugin_log::{Target, TargetKind}; - -pub fn register_plugins(app_builder: Builder) -> Builder { - let mut log_plugin_builder = tauri_plugin_log::Builder::new() - .targets([ - Target::new(TargetKind::Stdout), - Target::new(TargetKind::LogDir { file_name: None }), - Target::new(TargetKind::Webview), - ]) - .level_for("tao", log::LevelFilter::Off) - .level_for("os_info", log::LevelFilter::Off) - .level_for("notify", log::LevelFilter::Off) - .level_for("notify_debouncer_full", log::LevelFilter::Off); - - if tauri::is_dev() { - log_plugin_builder = log_plugin_builder.format(move |out, message, record| { - out.finish(format_args!( - "[{}][{}] {}", - match record.level() { - log::Level::Trace => "TRACE".bright_black().to_string(), - log::Level::Info => "INFO~".bright_blue().to_string(), - log::Level::Warn => "WARN~".yellow().to_string(), - log::Level::Error => "ERROR".red().to_string(), - log::Level::Debug => "DEBUG".bright_green().to_string(), - }, - if record.level() == log::Level::Error { - record - .file() - .map(|file| { - format!( - "{}:{}", - file.replace("\\", "/"), - record.line().unwrap_or_default() - ) - }) - .unwrap_or_else(|| record.target().to_owned()) - .bright_red() - .to_string() - } else { - record.target().bright_black().to_string() - }, - message - )) - }); - } - - app_builder - .plugin(tauri_plugin_fs::init()) - .plugin(tauri_plugin_shell::init()) - .plugin(tauri_plugin_dialog::init()) - .plugin(tauri_plugin_process::init()) - .plugin(tauri_plugin_updater::Builder::new().build()) - .plugin(tauri_plugin_autostart::init( - MacosLauncher::LaunchAgent, - Some(vec!["--silent"]), - )) - .plugin(log_plugin_builder.build()) - .plugin(tauri_plugin_deep_link::init()) - .plugin(tauri_plugin_http::init()) -} +use tauri::{Builder, Wry}; +use tauri_plugin_autostart::MacosLauncher; +use tauri_plugin_log::{Target, TargetKind}; + +pub fn register_plugins(app_builder: Builder) -> Builder { + let log_plugin_builder = tauri_plugin_log::Builder::new() + .targets([ + Target::new(TargetKind::Stdout), + Target::new(TargetKind::LogDir { file_name: None }), + Target::new(TargetKind::Webview), + ]) + .level_for("tao", log::LevelFilter::Off) + .level_for("os_info", log::LevelFilter::Off) + .level_for("notify", log::LevelFilter::Off) + .level_for("notify_debouncer_full", log::LevelFilter::Off); + + let log_plugin = { + #[cfg(not(dev))] + { + log_plugin_builder.build() + } + #[cfg(dev)] + { + use owo_colors::OwoColorize; + log_plugin_builder + .format(move |out, message, record| { + out.finish(format_args!( + "[{}][{}] {}", + match record.level() { + log::Level::Trace => "TRACE".bright_black().to_string(), + log::Level::Info => "INFO~".bright_blue().to_string(), + log::Level::Warn => "WARN~".yellow().to_string(), + log::Level::Error => "ERROR".red().to_string(), + log::Level::Debug => "DEBUG".bright_green().to_string(), + }, + if record.level() == log::Level::Error { + record + .file() + .map(|file| { + format!( + "{}:{}", + file.replace("\\", "/"), + record.line().unwrap_or_default() + ) + }) + .unwrap_or_else(|| record.target().to_owned()) + .bright_red() + .to_string() + } else { + record.target().bright_black().to_string() + }, + message + )) + }) + .build() + } + }; + + app_builder + .plugin(tauri_plugin_fs::init()) + .plugin(tauri_plugin_shell::init()) + .plugin(tauri_plugin_dialog::init()) + .plugin(tauri_plugin_process::init()) + .plugin(tauri_plugin_updater::Builder::new().build()) + .plugin(tauri_plugin_autostart::init( + MacosLauncher::LaunchAgent, + Some(vec!["--silent"]), + )) + .plugin(log_plugin) + .plugin(tauri_plugin_deep_link::init()) + .plugin(tauri_plugin_http::init()) +} diff --git a/src/background/seelen_weg/icon_extractor.rs b/src/background/seelen_weg/icon_extractor.rs index af245af7..ae8b93e3 100644 --- a/src/background/seelen_weg/icon_extractor.rs +++ b/src/background/seelen_weg/icon_extractor.rs @@ -1,4 +1,3 @@ -use color_eyre::eyre::eyre; use image::{GenericImageView, ImageBuffer, RgbaImage}; use itertools::Itertools; use windows::core::PCWSTR; @@ -57,7 +56,7 @@ pub fn convert_hicon_to_rgba_image(hicon: &HICON) -> Result { }; if !GetIconInfoExW(*hicon, &mut icon_info).as_bool() { - return Err(eyre!("Failed to get icon info").into()); + return Err("Failed to get icon info".into()); } let hdc_screen = CreateCompatibleDC(None); let hdc_mem = CreateCompatibleDC(hdc_screen); @@ -89,7 +88,7 @@ pub fn convert_hicon_to_rgba_image(hicon: &HICON) -> Result { DIB_RGB_COLORS, ) == 0 { - return Err(eyre!("Failed to get dibits").into()); + return Err("Failed to get dibits".into()); } // Clean up @@ -201,7 +200,7 @@ pub fn get_icon_from_file(path: &Path) -> Result { // file_info.iIcon = 0 is a valid icon but it is the default icon for files on Windows // so we will handle this as no icon to avoid generate unnecessary artifacts if result == 0 || file_info.iIcon == 0 { - return Err(eyre!("Failed to get icon").into()); + return Err("Failed to get icon".into()); } let image_list: IImageList = SHGetImageList(SHIL_JUMBO as i32)?; @@ -222,8 +221,8 @@ pub fn get_icon_from_url_file(path: &Path) -> Result { let mut path = None; // in theory .url files are encoded in UTF-8 so we don't need to use OsString - for line in reader.lines().map_while(Result::ok) { - if let Some(stripped) = line.strip_prefix("IconFile=") { + for line in reader.lines() { + if let Some(stripped) = line?.strip_prefix("IconFile=") { path = Some(PathBuf::from(stripped)); break; } @@ -231,7 +230,7 @@ pub fn get_icon_from_url_file(path: &Path) -> Result { let path = match path { Some(icon_file) => icon_file, - None => return Err(eyre!("Failed to get icon").into()), + None => return Err("Failed to get icon".into()), }; get_icon_from_file(&path) diff --git a/src/background/system/brightness.rs b/src/background/system/brightness.rs index 9ac13992..b3d1a88b 100644 --- a/src/background/system/brightness.rs +++ b/src/background/system/brightness.rs @@ -1,63 +1,63 @@ -use serde::Serialize; -use windows::Win32::Devices::Display::{ - GetMonitorBrightness, GetMonitorCapabilities, SetMonitorBrightness, -}; - -use crate::windows_api::WindowsApi; - -#[derive(Debug, Serialize)] -pub struct Brightness { - min: u32, - max: u32, - current: u32, -} - -#[tauri::command(async)] -pub fn get_main_monitor_brightness() -> Result { - let mut brightness = Brightness { - min: 0, - max: 0, - current: 0, - }; - - unsafe { - let hmonitor = WindowsApi::primary_physical_monitor()?; - - let mut pdwmonitorcapabilities: u32 = 0; - let mut pdwsupportedcolortemperatures: u32 = 0; - let mut result = GetMonitorCapabilities( - hmonitor.hPhysicalMonitor, - &mut pdwmonitorcapabilities, - &mut pdwsupportedcolortemperatures, - ); - - if result == 0 { - return Err("GetMonitorCapabilities failed".to_string()); - } - - result = GetMonitorBrightness( - hmonitor.hPhysicalMonitor, - &mut brightness.min, - &mut brightness.current, - &mut brightness.max, - ); - - if result == 0 { - return Err("GetMonitorBrightness failed".to_string()); - } - } - - Ok(brightness) -} - -#[tauri::command(async)] -pub fn set_main_monitor_brightness(brightness: u32) -> Result<(), String> { - let result = unsafe { - let hmonitor = WindowsApi::primary_physical_monitor()?; - SetMonitorBrightness(hmonitor.hPhysicalMonitor, brightness) - }; - if result == 0 { - return Err("SetMonitorBrightness failed".to_string()); - } - Ok(()) -} +use serde::Serialize; +use windows::Win32::Devices::Display::{ + GetMonitorBrightness, GetMonitorCapabilities, SetMonitorBrightness, +}; + +use crate::{error_handler::Result, windows_api::WindowsApi}; + +#[derive(Debug, Serialize)] +pub struct Brightness { + min: u32, + max: u32, + current: u32, +} + +#[tauri::command(async)] +pub fn get_main_monitor_brightness() -> Result { + let mut brightness = Brightness { + min: 0, + max: 0, + current: 0, + }; + + unsafe { + let hmonitor = WindowsApi::primary_physical_monitor()?; + + let mut pdwmonitorcapabilities: u32 = 0; + let mut pdwsupportedcolortemperatures: u32 = 0; + let mut result = GetMonitorCapabilities( + hmonitor.hPhysicalMonitor, + &mut pdwmonitorcapabilities, + &mut pdwsupportedcolortemperatures, + ); + + if result == 0 { + return Err("GetMonitorCapabilities failed".into()); + } + + result = GetMonitorBrightness( + hmonitor.hPhysicalMonitor, + &mut brightness.min, + &mut brightness.current, + &mut brightness.max, + ); + + if result == 0 { + return Err("GetMonitorBrightness failed".into()); + } + } + + Ok(brightness) +} + +#[tauri::command(async)] +pub fn set_main_monitor_brightness(brightness: u32) -> Result<()> { + let result = unsafe { + let hmonitor = WindowsApi::primary_physical_monitor()?; + SetMonitorBrightness(hmonitor.hPhysicalMonitor, brightness) + }; + if result == 0 { + return Err("SetMonitorBrightness failed".into()); + } + Ok(()) +} diff --git a/src/background/windows_api/mod.rs b/src/background/windows_api/mod.rs index a5446dcd..700f774c 100644 --- a/src/background/windows_api/mod.rs +++ b/src/background/windows_api/mod.rs @@ -22,7 +22,6 @@ use std::{ time::Duration, }; -use color_eyre::eyre::eyre; use windows::{ core::{BSTR, GUID, PCWSTR, PWSTR}, Storage::Streams::{ @@ -100,7 +99,7 @@ use windows::{ }; use crate::{ - error_handler::{AppError, Result}, + error_handler::Result, hook::HookManager, modules::input::{domain::Point, Mouse}, utils::{is_virtual_desktop_supported, is_windows_11}, @@ -196,7 +195,7 @@ impl WindowsApi { if ProcessIdToSessionId(process_id, &mut session_id).is_ok() { Ok(session_id) } else { - Err(eyre!("could not determine current session id").into()) + Err("could not determine current session id".into()) } } } @@ -496,7 +495,7 @@ impl WindowsApi { Ok(Self::exe_path(hwnd)? .split('\\') .last() - .ok_or_else(|| eyre!("there is no last element"))? + .ok_or("there is no last element")? .to_string()) } @@ -670,7 +669,7 @@ impl WindowsApi { pub fn monitor_name(hmonitor: HMONITOR) -> Result { let ex_info = Self::monitor_info(hmonitor)?; Ok(U16CStr::from_slice_truncate(&ex_info.szDevice) - .map_err(|_| AppError::Seelen("monitor name was not a valid u16 c string".to_owned()))? + .map_err(|_| "monitor name was not a valid u16 c string")? .to_ustring() .to_string_lossy() .trim_start_matches(r"\\.\") @@ -727,7 +726,7 @@ impl WindowsApi { } } if desktop_id.to_u128() == 0 { - return Err(eyre!("Failed to get desktop id for: {hwnd:?}").into()); + return Err(format!("Failed to get desktop id for: {hwnd:?}").into()); } Ok(desktop_id) } @@ -816,7 +815,7 @@ impl WindowsApi { pub fn set_suspend_state() -> Result<()> { let success = unsafe { SetSuspendState(false, true, false).as_bool() }; if !success { - return Err(eyre!("Failed to set suspend state").into()); + return Err("Failed to set suspend state".into()); } Ok(()) } diff --git a/tauri.conf.json b/tauri.conf.json index b6955cb0..74cf5837 100644 --- a/tauri.conf.json +++ b/tauri.conf.json @@ -30,9 +30,10 @@ }, "bundle": { "active": true, - "resources": [ - "static/**/*" - ], + "resources": { + "static/": "static/", + "target/release/seelen_ui.pdb": "seelen_ui.pdb" + }, "targets": [ "nsis" ], @@ -50,16 +51,23 @@ "startMenuFolder": "Seelen", "displayLanguageSelector": true, "languages": [ - "English", - "German", - "Spanish", - "French", - "Hindi", - "Portuguese", - "Japanese", - "Korean", - "SimpChinese", - "TradChinese" + "arabic", + "bulgarian", + "dutch", + "english", + "german", + "italian", + "japanese", + "korean", + "portuguesebr", + "russian", + "tradchinese", + "simpchinese", + "french", + "spanish", + "persian", + "turkish", + "swedish" ] } },