                         extraResponse.statusCode = hresponse.statusCode
                     }
                     extraResponse.responseObject = responseObject
-                    if success != nil {
+                    if extraResponse.statusCode > 299 {
+                        if failure != nil {
+                            failure(self.createError(extraResponse.statusCode!))
+                        }
+                    } else if success != nil {
                         success(extraResponse)
                     }
                 } else if failure != nil {

            var split = url.hasPrefix("/") ? "" : "/"
            urlVal = "\(self.baseURL!)\(split)\(url)"
        }
        if self.requestSerializer == nil {
            self.requestSerializer = HTTPRequestSerializer()
        }
        return self.requestSerializer.createRequest(NSURL.URLWithString(urlVal),
            method: method, parameters: parameters)
        

public class HTTPTask : NSObject, NSURLSessionDelegate {
    
    var baseURL: String?
    var requestSerializer = HTTPRequestSerializer()
    var responseSerializer: HTTPResponseSerializer?
    //these 2 only get used for background download/upload since they have to be delegate methods
    var backgroundSuccess:((AnyObject?) -> Void)?
