<NME> errors.rs
<BEF> ADDFILE
<MSG> Create general SwapBuffersError

<DFF> @@ -0,0 +1,46 @@
+use std::fmt;
+use std::error::Error;
+
+/// Error that can happen when swapping buffers.
+#[derive(Debug, Clone, PartialEq)]
+pub enum SwapBuffersError {
+    /// The corresponding context has been lost and needs to be recreated.
+    ///
+    /// All the objects associated to it (textures, buffers, programs, etc.)
+    /// need to be recreated from scratch.
+    ///
+    /// Operations will have no effect. Functions that read textures, buffers, etc.
+    /// will return uninitialized data instead.
+    ContextLost,
+    /// The buffers have already been swapped.
+    ///
+    /// This error can be returned when `swap_buffers` has been called multiple times
+    /// without any modification in between.
+    AlreadySwapped,
+    /// Unknown error
+    Unknown(u32),
+}
+
+impl fmt::Display for SwapBuffersError {
+    fn fmt(&self, formatter: &mut fmt::Formatter) -> Result<(), fmt::Error> {
+        use std::error::Error;
+        write!(formatter, "{}", self.description())
+    }
+}
+
+impl Error for SwapBuffersError {
+    fn description(&self) -> &str {
+        match *self {
+            SwapBuffersError::ContextLost => "The context has been lost, it needs to be recreated",
+            SwapBuffersError::AlreadySwapped => {
+                "Buffers are already swapped, swap_buffers was called too many times"
+            }
+            SwapBuffersError::Unknown(_) => "Unknown error occurred",
+        }
+    }
+
+    fn cause(&self) -> Option<&Error> {
+        None
+    }
+}
+

Create general SwapBuffersError