switch to color_eyre instead of anyhow

This commit is contained in:
Nova
2022-12-02 13:58:54 -05:00
parent 03ccf9127d
commit d7a607a663
29 changed files with 114 additions and 118 deletions

View File

@@ -5,7 +5,7 @@ use crate::{
Node,
},
};
use anyhow::{ensure, Result};
use color_eyre::eyre::{ensure, Result};
use glam::Vec3A;
use mint::Vector3;
use parking_lot::Mutex;

View File

@@ -4,7 +4,7 @@ pub mod text;
use super::Node;
use crate::core::client::Client;
use anyhow::Result;
use color_eyre::eyre::Result;
use parking_lot::Mutex;
use serde::Deserialize;
use stardust_xr::schemas::flex::deserialize;

View File

@@ -4,7 +4,7 @@ use crate::core::destroy_queue;
use crate::core::registry::Registry;
use crate::core::resource::ResourceID;
use crate::nodes::spatial::{find_spatial_parent, parse_transform, Spatial};
use anyhow::{anyhow, ensure, Result};
use color_eyre::eyre::{ensure, eyre, Result};
use once_cell::sync::OnceCell;
use parking_lot::Mutex;
use prisma::{Rgb, Rgba};
@@ -66,12 +66,12 @@ impl Model {
.get_file(
&node
.get_client()
.ok_or_else(|| anyhow!("Client not found"))?
.ok_or_else(|| eyre!("Client not found"))?
.base_resource_prefixes
.lock()
.clone(),
)
.ok_or_else(|| anyhow!("Resource not found"))?,
.ok_or_else(|| eyre!("Resource not found"))?,
);
let _ = node.model.set(model_arc.clone());
Ok(model_arc)

View File

@@ -5,7 +5,7 @@ use crate::{
Node,
},
};
use anyhow::{anyhow, ensure, Result};
use color_eyre::eyre::{ensure, eyre, Result};
use glam::{vec3, Mat4, Vec2};
use mint::Vector2;
use once_cell::sync::OnceCell;
@@ -63,9 +63,7 @@ impl Text {
"Internal: Node already has text attached!"
);
let client = node
.get_client()
.ok_or_else(|| anyhow!("Client not found"))?;
let client = node.get_client().ok_or_else(|| eyre!("Client not found"))?;
let text = TEXT_REGISTRY.add(Text {
space: node.spatial.get().unwrap().clone(),
font_path: font_resource_id
@@ -90,21 +88,21 @@ impl Text {
}
fn draw(&self, sk: &StereoKit, draw_ctx: &DrawContext) {
let style =
self.style
.get_or_try_init(|| -> Result<SendWrapper<TextStyle>, anyhow::Error> {
let font = self
.font_path
.as_deref()
.and_then(|path| Font::from_file(sk, path))
.unwrap_or(Font::default(sk));
Ok(SendWrapper::new(TextStyle::new(
sk,
font,
1.0,
Rgba::new(Rgb::new(1.0, 1.0, 1.0), 1.0),
)))
});
let style = self.style.get_or_try_init(
|| -> Result<SendWrapper<TextStyle>, color_eyre::eyre::Error> {
let font = self
.font_path
.as_deref()
.and_then(|path| Font::from_file(sk, path))
.unwrap_or(Font::default(sk));
Ok(SendWrapper::new(TextStyle::new(
sk,
font,
1.0,
Rgba::new(Rgb::new(1.0, 1.0, 1.0), 1.0),
)))
},
);
if let Ok(style) = style {
let data = self.data.lock();