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)?;
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ use std::{
|
||||
sync::Arc,
|
||||
};
|
||||
|
||||
use anyhow::Context;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use wlx_common::{common::LeftRight, config::GeneralConfig, windowing::Positioning};
|
||||
|
||||
@@ -187,7 +188,7 @@ impl WayVRConfig {
|
||||
keyboard_repeat_delay_ms: config_wayvr.keyboard_repeat_delay,
|
||||
keyboard_repeat_rate: config_wayvr.keyboard_repeat_rate,
|
||||
blit_method: wayvr::BlitMethod::from_string(&config_wayvr.blit_method)
|
||||
.ok_or_else(|| anyhow::anyhow!("Unknown blit method"))?,
|
||||
.context("unknown blit method")?,
|
||||
auto_hide_delay: if config_wayvr.auto_hide {
|
||||
Some(config_wayvr.auto_hide_delay)
|
||||
} else {
|
||||
|
||||
@@ -4,23 +4,24 @@ use std::{
|
||||
sync::Arc,
|
||||
};
|
||||
|
||||
use anyhow::Context;
|
||||
use smallvec::SmallVec;
|
||||
use vulkano::{
|
||||
VulkanError, VulkanObject,
|
||||
device::Device,
|
||||
format::Format,
|
||||
image::{Image, ImageCreateInfo, ImageTiling, ImageUsage, SubresourceLayout, sys::RawImage},
|
||||
image::{sys::RawImage, Image, ImageCreateInfo, ImageTiling, ImageUsage, SubresourceLayout},
|
||||
memory::{
|
||||
allocator::{MemoryAllocator, MemoryTypeFilter},
|
||||
DedicatedAllocation, DeviceMemory, ExternalMemoryHandleType, ExternalMemoryHandleTypes,
|
||||
MemoryAllocateInfo, MemoryImportInfo, MemoryPropertyFlags, ResourceMemory,
|
||||
allocator::{MemoryAllocator, MemoryTypeFilter},
|
||||
},
|
||||
sync::Sharing,
|
||||
VulkanError, VulkanObject,
|
||||
};
|
||||
use wgui::gfx::WGfx;
|
||||
use wlx_capture::frame::{
|
||||
DRM_FORMAT_ABGR8888, DRM_FORMAT_ABGR2101010, DRM_FORMAT_ARGB8888, DRM_FORMAT_XBGR8888,
|
||||
DRM_FORMAT_XBGR2101010, DRM_FORMAT_XRGB8888, DmabufFrame, DrmFormat, FourCC,
|
||||
DmabufFrame, DrmFormat, FourCC, DRM_FORMAT_ABGR2101010, DRM_FORMAT_ABGR8888,
|
||||
DRM_FORMAT_ARGB8888, DRM_FORMAT_XBGR2101010, DRM_FORMAT_XBGR8888, DRM_FORMAT_XRGB8888,
|
||||
};
|
||||
|
||||
pub const DRM_FORMAT_MOD_INVALID: u64 = 0xff_ffff_ffff_ffff;
|
||||
@@ -74,7 +75,7 @@ impl WGfxDmabuf for WGfx {
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
.ok_or_else(|| anyhow::anyhow!("failed to get memory type index"))?;
|
||||
.context("failed to get memory type index")?;
|
||||
|
||||
debug_assert!(self.device.enabled_extensions().khr_external_memory_fd);
|
||||
debug_assert!(self.device.enabled_extensions().khr_external_memory);
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
use anyhow::Context;
|
||||
use glam::FloatExt;
|
||||
use wgui::{
|
||||
animation::{Animation, AnimationEasing},
|
||||
@@ -24,7 +25,7 @@ impl InteractLockHandler {
|
||||
.state
|
||||
.widgets
|
||||
.get_as::<WidgetRectangle>(id)
|
||||
.ok_or_else(|| anyhow::anyhow!("Element with id=\"shadow\" must be a <rectangle>"))?;
|
||||
.context("Element with id=\"shadow\" must be a <rectangle>")?;
|
||||
|
||||
Ok(Self {
|
||||
id,
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
use anyhow::Context;
|
||||
use glam::{vec3, Affine2, Affine3A, Quat, Vec3};
|
||||
use smallvec::smallvec;
|
||||
use std::{cell::RefCell, collections::HashMap, rc::Rc, sync::Arc};
|
||||
@@ -677,7 +678,7 @@ impl OverlayBackend for WayVRBackend {
|
||||
.data
|
||||
.state
|
||||
.get_render_data(ctx.display)
|
||||
.ok_or_else(|| anyhow::anyhow!("Failed to fetch render data"))?
|
||||
.context("Failed to fetch render data")?
|
||||
.clone();
|
||||
|
||||
drop(wayvr);
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
use anyhow::Context;
|
||||
use wlx_capture::wayland::wayland_client::{
|
||||
Connection, Dispatch, Proxy, QueueHandle,
|
||||
globals::{GlobalListContents, registry_queue_init},
|
||||
globals::{registry_queue_init, GlobalListContents},
|
||||
protocol::{
|
||||
wl_keyboard::{self, WlKeyboard},
|
||||
wl_registry::WlRegistry,
|
||||
wl_seat::{self, Capability, WlSeat},
|
||||
},
|
||||
Connection, Dispatch, Proxy, QueueHandle,
|
||||
};
|
||||
use xkbcommon::xkb;
|
||||
|
||||
@@ -46,9 +47,7 @@ pub fn get_keymap_wl() -> anyhow::Result<XkbKeymap> {
|
||||
// this gets us the wl_keyboard
|
||||
let _ = queue.blocking_dispatch(&mut me);
|
||||
|
||||
me.keymap
|
||||
.take()
|
||||
.ok_or_else(|| anyhow::anyhow!("Could not load keymap"))
|
||||
me.keymap.take().context("could not load keymap")
|
||||
}
|
||||
|
||||
impl Dispatch<WlRegistry, GlobalListContents> for WlKeymapHandler {
|
||||
|
||||
Reference in New Issue
Block a user