From 48cbf3746550e7c17f16e5c24dda6afd96b2fec1 Mon Sep 17 00:00:00 2001 From: Kyle Strohbeck Date: Fri, 9 Dec 2016 12:14:28 -0600 Subject: [PATCH] Implement Error for UpdateTextureError. --- src/sdl2/render.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/sdl2/render.rs b/src/sdl2/render.rs index 2d3e4133..703fc1f4 100644 --- a/src/sdl2/render.rs +++ b/src/sdl2/render.rs @@ -1069,6 +1069,22 @@ impl fmt::Display for UpdateTextureError { } } +impl Error for UpdateTextureError { + fn description(&self) -> &str { + use self::UpdateTextureError::*; + + match *self { + PitchOverflows(_) => "pitch overflow", + PitchMustBeMultipleOfTwoForFormat(..) => "pitch must be multiple of two", + XMustBeMultipleOfTwoForFormat(..) => "x must be multiple of two", + YMustBeMultipleOfTwoForFormat(..) => "y must be multiple of two", + WidthMustBeMultipleOfTwoForFormat(..) => "width must be multiple of two", + HeightMustBeMultipleOfTwoForFormat(..) => "height must be multiple of two", + SdlError(ref e) => e, + } + } +} + #[derive(Debug)] pub enum UpdateTextureYUVError { PitchOverflows { plane: &'static str, value: usize },