From c1f79b40cf704cafc807250b177fc7d3444fe54f Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Tue, 8 Sep 2020 00:35:17 +0200 Subject: Make `Application` and `Sandbox` return a `Result` --- wgpu/src/window/compositor.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'wgpu/src/window') diff --git a/wgpu/src/window/compositor.rs b/wgpu/src/window/compositor.rs index c790f35f..79ffacdd 100644 --- a/wgpu/src/window/compositor.rs +++ b/wgpu/src/window/compositor.rs @@ -1,7 +1,6 @@ -use crate::{Backend, Color, Renderer, Settings}; +use crate::{Backend, Color, Error, Renderer, Settings, Viewport}; use futures::task::SpawnExt; -use iced_graphics::Viewport; use iced_native::{futures, mouse}; use raw_window_handle::HasRawWindowHandle; @@ -82,13 +81,13 @@ impl iced_graphics::window::Compositor for Compositor { type Surface = wgpu::Surface; type SwapChain = wgpu::SwapChain; - fn new(settings: Self::Settings) -> (Self, Renderer) { + fn new(settings: Self::Settings) -> Result<(Self, Renderer), Error> { let compositor = futures::executor::block_on(Self::request(settings)) - .expect("Could not find a suitable graphics adapter"); + .ok_or(Error::AdapterNotFound)?; let backend = compositor.create_backend(); - (compositor, Renderer::new(backend)) + Ok((compositor, Renderer::new(backend))) } fn create_surface( -- cgit