From 90ebe377dfcc9d87d731fb4e4eaf41887ce5618b Mon Sep 17 00:00:00 2001 From: Connor Fitzgerald Date: Thu, 16 Jul 2020 09:11:22 -0400 Subject: [PATCH] [rs] Impl Error for Error types --- wgpu/src/lib.rs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/wgpu/src/lib.rs b/wgpu/src/lib.rs index c2a274120f..ec024672e2 100644 --- a/wgpu/src/lib.rs +++ b/wgpu/src/lib.rs @@ -1254,10 +1254,26 @@ impl Drop for Device { #[derive(Clone, PartialEq, Eq, Debug)] pub struct RequestDeviceError; -/// Error occurred when trying to async map a number. +impl std::fmt::Display for RequestDeviceError { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "Requesting a device failed") + } +} + +impl std::error::Error for RequestDeviceError {} + +/// Error occurred when trying to async map a buffer. #[derive(Clone, PartialEq, Eq, Debug)] pub struct BufferAsyncError; +impl std::fmt::Display for BufferAsyncError { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "Error occurred when trying to async map a buffer") + } +} + +impl std::error::Error for BufferAsyncError {} + /// Type of buffer mapping. #[derive(Debug, Clone, Copy, PartialEq)] pub enum MapMode {