From fb1bff71ebe5cc4b4f95f700cd0b0f90f117db97 Mon Sep 17 00:00:00 2001 From: Kevin Fuller Date: Thu, 30 Jun 2016 09:28:50 -0700 Subject: [PATCH] Implement Error for TextureValueError --- src/sdl2/render.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/sdl2/render.rs b/src/sdl2/render.rs index 624a444d..34b4469c 100644 --- a/src/sdl2/render.rs +++ b/src/sdl2/render.rs @@ -35,6 +35,7 @@ use pixels; use pixels::PixelFormatEnum; use get_error; use std::fmt; +use std::error::Error; use std::mem; use std::ptr; use libc::{c_int, uint32_t, c_double, c_void}; @@ -356,6 +357,19 @@ impl fmt::Display for TextureValueError { } } +impl Error for TextureValueError { + fn description(&self) -> &str { + use self::TextureValueError::*; + + match *self { + WidthOverflows(_) => "texture width overflow", + HeightOverflows(_) => "texture height overflow", + WidthMustBeMultipleOfTwoForFormat(..) => "texture width must be multiple of two", + SdlError(ref e) => e, + } + } +} + /// Texture-creating methods for the renderer impl<'a> Renderer<'a> { /// Creates a texture for a rendering context.