fix(wm): don't err on failed window serialization

This commit is contained in:
LGUG2Z
2022-04-20 13:47:44 -07:00
parent 711ab8d59b
commit 61760fc77d
+5 -6
View File
@@ -5,7 +5,7 @@ use std::fmt::Formatter;
use color_eyre::eyre::anyhow; use color_eyre::eyre::anyhow;
use color_eyre::Result; use color_eyre::Result;
use schemars::JsonSchema; use schemars::JsonSchema;
use serde::ser::Error;
use serde::ser::SerializeStruct; use serde::ser::SerializeStruct;
use serde::Serialize; use serde::Serialize;
use serde::Serializer; use serde::Serializer;
@@ -64,24 +64,23 @@ impl Serialize for Window {
"title", "title",
&self &self
.title() .title()
.map_err(|_| S::Error::custom("could not get window title"))?, .unwrap_or_else(|_| "could not get window title".to_string()),
)?; )?;
state.serialize_field( state.serialize_field(
"exe", "exe",
&self &self
.exe() .exe()
.map_err(|_| S::Error::custom("could not get window exe"))?, .unwrap_or_else(|_| "could not get window exe".to_string()),
)?; )?;
state.serialize_field( state.serialize_field(
"class", "class",
&self &self
.class() .class()
.map_err(|_| S::Error::custom("could not get window class"))?, .unwrap_or_else(|_| "could not get window class".to_string()),
)?; )?;
state.serialize_field( state.serialize_field(
"rect", "rect",
&WindowsApi::window_rect(self.hwnd()) &WindowsApi::window_rect(self.hwnd()).unwrap_or_default(),
.map_err(|_| S::Error::custom("could not get window rect"))?,
)?; )?;
state.end() state.end()
} }