improve error handling

This commit is contained in:
galister
2024-02-18 22:24:36 +01:00
parent 615470aa92
commit 63b43c0e59
17 changed files with 517 additions and 611 deletions

View File

@@ -1,5 +1,8 @@
use glam::Affine3A;
use ovr_overlay::{pose::Matrix3x4, sys::HmdMatrix34_t};
use thiserror::Error;
use crate::backend::common::BackendError;
pub trait Affine3AConvert {
fn from_affine(affine: Affine3A) -> Self;
@@ -75,3 +78,21 @@ impl Affine3AConvert for HmdMatrix34_t {
])
}
}
#[derive(Error, Debug)]
pub(super) enum OVRError {
#[error("ovr input error: {0}")]
InputError(&'static str),
}
impl From<ovr_overlay::errors::EVRInputError> for OVRError {
fn from(e: ovr_overlay::errors::EVRInputError) -> Self {
OVRError::InputError(e.description())
}
}
impl From<OVRError> for BackendError {
fn from(e: OVRError) -> Self {
BackendError::Fatal(anyhow::Error::new(e))
}
}