             return nil
         }
     }
-    
+
+    public class func responseErrorFromObject(object: AnyObject) -> NSError {
+        let userInfo = [NSLocalizedDescriptionKey: "received status code that represents error"]
+        let error = NSError(domain: APIKitErrorDomain, code: 0, userInfo: userInfo)
+        return error
+    }
+
     // MARK: - NSURLSessionTaskDelegate
     // TODO: add attributes like NS_REQUIRES_SUPER when it is available in future version of Swift.
     public func URLSession(session: NSURLSession, task: NSURLSessionTask, didCompleteWithError connectionError: NSError?) {

                        let error = NSError(domain: APIKitErrorDomain, code: 0, userInfo: userInfo)
                        return failure(error)
                    }
                    
                }
                dispatch_async(mainQueue, { handler(mappedResponse) })
            }
            

                
                let statusCode = (URLResponse as? NSHTTPURLResponse)?.statusCode ?? 0
                if !contains(self.acceptableStatusCodeRange, statusCode) {
                    var error: NSError = {
                        switch self.responseBodyParser().parseData(data) {
                        case .Success(let box): return self.responseErrorFromObject(box.unbox)
                        case .Failure(let box): return box.unbox
                        }
                    }()

                    dispatch_async(mainQueue) { handler(failure(error)) }
                    return
                }
                
