So I'm using PromiseKit in my latest swift app to do most of the networking code, along with Alamofire. I'm trying to setup my promises to throw when my returns aren't what I desire - here's what the code looks like:
`
do{
firstly({
try DoStuff.doStuff()
}).then({ response in
self.array = response
}).error { error in
throw Error.GeneralError
print(error)
}
firstly({
try DoOtherThing.otherThing()
}).then({ response in
self.stuff = response
}).error{ error in
throw TransactionError.GeneralError
print(error)
}
} catch {
let alertController = UIAlertController(title: "Network Error", message: "Network error, please try again", preferredStyle: .Alert)
let OKAction = UIAlertAction(title: "OK", style: .Default) { (action) in
//
}
alertController.addAction(OKAction)
self.presentViewController(alertController, animated: true) {
//
}
}
`
This code works just hunky dory if I don't have the 'throw' statements in there - if I just print the error, or put my alert controller code in there, works as expected. But when I add the throw, I get an compiler red flag on the 'error' line that says Cannot call value of non function type 'ErrorType'
Any thoughts? Thanks