use std::fmt;
use ansi_term::Colour;

#[derive(Debug)]
pub enum ErrorLevel {
    Info,
    Warning,
    Error,
}

pub struct Error(pub (ErrorLevel, &'static str));

impl fmt::Display for Error {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        let colour_level = match (self.0).0 {
            ErrorLevel::Info => Colour::Yellow.paint("Info"),

            // ansi_term does not have orange for some reason
            ErrorLevel::Warning => Colour::RGB(255, 210, 0).paint("Warning"),
            ErrorLevel::Error => Colour::Red.paint("Error"),
        };

        write!(f, "[{:?}] {}\n", colour_level, (self.0).1)
    }
}

// Use a hashmap which contains an error level and a string
pub struct ErrorStack(pub Vec<Error>);

impl fmt::Display for ErrorStack {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        for error in &self.0 {
            // TODO: Remove this unwrap
            write!(f, "{}\n", error).unwrap();
        }

        write!(f, "")
    }
}

use std::fmt;

#[derive(Debug)]
pub enum ErrorLevel {
    Info,
    Warning,
    Error,
}

pub struct Error(pub (ErrorLevel, &'static str));

impl fmt::Display for Error {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(f, "[{:?}] {}", (self.0).0, (self.0).1)
    }
}

// Use a hashmap which contains an error level and a string
pub struct ErrorStack(pub Vec<Error>);

impl fmt::Display for ErrorStack {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        for error in &self.0 {
            // TODO: Remove this unwrap
            write!(f, "{}", error).unwrap();
        }

        write!(f, "")
    }
}

--- 
+++ 
@@ -1,5 +1,4 @@
 use std::fmt;
-use ansi_term::Colour;
 
 #[derive(Debug)]
 pub enum ErrorLevel {
@@ -12,15 +11,7 @@
 
 impl fmt::Display for Error {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        let colour_level = match (self.0).0 {
-            ErrorLevel::Info => Colour::Yellow.paint("Info"),
-
-            // ansi_term does not have orange for some reason
-            ErrorLevel::Warning => Colour::RGB(255, 210, 0).paint("Warning"),
-            ErrorLevel::Error => Colour::Red.paint("Error"),
-        };
-
-        write!(f, "[{:?}] {}\n", colour_level, (self.0).1)
+        write!(f, "[{:?}] {}", (self.0).0, (self.0).1)
     }
 }
 
@@ -31,7 +22,7 @@
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         for error in &self.0 {
             // TODO: Remove this unwrap
-            write!(f, "{}\n", error).unwrap();
+            write!(f, "{}", error).unwrap();
         }
 
         write!(f, "")
Add a colour level to error levels
