         throw RepositoryError.StatusFail(message: message, code: code)
     }
     
-    private func getErrorFromResponse(response: NSURLResponse) -> ErrorType? {
+    private func getErrorFromResponse(response: NSURLResponse, data: NSData?) -> RepositoryError? {
         guard let httpResponse = response as? NSHTTPURLResponse else {
             return nil
         }
         let code = httpResponse.statusCode
         if code >= 400 && code < 600 {
-            return RepositoryError.HTTPError(statusCode: code)
+            var message: String?
+            if let data = data {
+                message = String(data: data, encoding: NSISOLatin1StringEncoding)
+            }
+            return RepositoryError.HTTPError(statusCode: code, message: message)
         }
         return nil
     }

                        if let error = error {
                            throw error
                        }
                        if let response = response, error = self.getErrorFromResponse(response) {
                            throw error
                        }
                        guard let data = data else {

    case JSON
}

public enum RepositoryError: ErrorType, CustomStringConvertible {
    case BadJSON
    case BadJSONContent
    case InvalidURL
    case InvalidParameters
//    case RequestError(message: String?)
    case StatusFail(message: String?, code: String?)
    case NetworkConnection
    case HTTPError(statusCode: Int, message: String?)
    case EncodingError
    
    public var description: String {
        switch self {
        case .HTTPError(let statusCode, _):
            return "HTTP Error: \(statusCode)"
        case BadJSON:
            return "Bad JSON"
        case .BadJSONContent:
            return "Bad JOSN Content"
        case InvalidURL:
            return "Invalid URL"
        case InvalidParameters:
            return "Invalid parameters"
        case StatusFail(let message, let code):
            return "Status fail(\(code)): \(message)"
        case NetworkConnection:
            return "No network connection"
        case EncodingError:
            return "Encoding error"
        }
    }
}

public protocol URLConvertible {
