Error Handling with Alamofire in Swift 2

Viewed 3631

Hi I am practising some code, my code is fine with case .Success(let value): and it is displaying alert but will case .Failure(let error): display alert with The 4xx class of status code?

  Alamofire.request(.GET, URL).responseJSON { (response) -> Void in
            if let value = response.result.value {

             let json = JSON(value)

             switch response.result {
             case .Success(let value):

             let name = json["name"].string
             if let nothing = name {
             self.alertMessage(message: "Name not Found")
                    } else {
            self.alertMessage(message: "Name Found")
                    }
            case .Failure(let error):
            self.alertMessage(message: "Error 4xx / 5xx")
                }
1 Answers
Related