anyhow context is nice
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
use std::{fs::File, io::Read};
|
||||
|
||||
use anyhow::bail;
|
||||
use anyhow::{bail, Context};
|
||||
use json::{array, object};
|
||||
use ovr_overlay::applications::ApplicationsManager;
|
||||
|
||||
@@ -18,7 +18,7 @@ pub(super) fn install_manifest(app_mgr: &mut ApplicationsManager) -> anyhow::Res
|
||||
Ok(ref path) => path,
|
||||
Err(_) => executable_pathbuf
|
||||
.to_str()
|
||||
.ok_or_else(|| anyhow::anyhow!("Invalid executable path"))?,
|
||||
.context("Invalid executable path")?,
|
||||
};
|
||||
|
||||
if app_mgr.is_application_installed(APP_KEY) == Ok(true)
|
||||
|
||||
@@ -6,7 +6,7 @@ use crate::backend::wayvr::egl_ex::{
|
||||
};
|
||||
|
||||
use super::egl_ex;
|
||||
use anyhow::anyhow;
|
||||
use anyhow::{anyhow, Context};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct EGLData {
|
||||
@@ -83,9 +83,9 @@ fn get_disp(
|
||||
|
||||
egl
|
||||
.get_display(khronos_egl::DEFAULT_DISPLAY)
|
||||
.ok_or_else(|| anyhow!(
|
||||
.context(
|
||||
"Both eglGetPlatformDisplayEXT and eglGetDisplay failed. This shouldn't happen unless you don't have any display manager running. Cannot continue, check your EGL installation."
|
||||
))
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,7 +113,7 @@ impl EGLData {
|
||||
|
||||
let config = egl
|
||||
.choose_first_config(display, &attrib_list)?
|
||||
.ok_or_else(|| anyhow!("Failed to get EGL config"))?;
|
||||
.context("Failed to get EGL config")?;
|
||||
|
||||
egl.bind_api(khronos_egl::OPENGL_ES_API)?;
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ pub mod server_ipc;
|
||||
mod smithay_wrapper;
|
||||
mod time;
|
||||
mod window;
|
||||
use anyhow::Context;
|
||||
use comp::Application;
|
||||
use display::{Display, DisplayInitParams, DisplayVec};
|
||||
use event_queue::SyncEventQueue;
|
||||
@@ -20,9 +21,9 @@ use smallvec::SmallVec;
|
||||
use smithay::{
|
||||
backend::{
|
||||
egl,
|
||||
renderer::{ImportDma, gles::GlesRenderer},
|
||||
renderer::{gles::GlesRenderer, ImportDma},
|
||||
},
|
||||
input::{SeatState, keyboard::XkbConfig},
|
||||
input::{keyboard::XkbConfig, SeatState},
|
||||
output::{Mode, Output},
|
||||
reexports::wayland_server::{self, backend::ClientId},
|
||||
wayland::{
|
||||
@@ -44,7 +45,7 @@ use wayvr_ipc::{packet_client, packet_server};
|
||||
|
||||
use crate::{
|
||||
state::AppState,
|
||||
subsystem::hid::{MODS_TO_KEYS, WheelDelta},
|
||||
subsystem::hid::{WheelDelta, MODS_TO_KEYS},
|
||||
};
|
||||
|
||||
const STR_INVALID_HANDLE_DISP: &str = "Invalid display handle";
|
||||
@@ -283,7 +284,7 @@ impl WayVR {
|
||||
.state
|
||||
.displays
|
||||
.get_mut(&display)
|
||||
.ok_or_else(|| anyhow::anyhow!(STR_INVALID_HANDLE_DISP))?;
|
||||
.context(STR_INVALID_HANDLE_DISP)?;
|
||||
|
||||
/* Buffer warm-up is required, always two first calls of this function are always rendered */
|
||||
if !display.wants_redraw && display.rendered_frame_count >= 2 {
|
||||
@@ -695,7 +696,7 @@ impl WayVRState {
|
||||
let display = self
|
||||
.displays
|
||||
.get_mut(&display_handle)
|
||||
.ok_or_else(|| anyhow::anyhow!(STR_INVALID_HANDLE_DISP))?;
|
||||
.context(STR_INVALID_HANDLE_DISP)?;
|
||||
|
||||
let res = display.spawn_process(exec_path, args, env, working_dir)?;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user