title: how to throw errors in a closure in swift?
body: <p>Please look at the following code:</p>
  
  <pre><code>override func tableView(tableView: UITableView, editActionsForRowAtIndexPath indexPath: NSIndexPath) -&gt; [UITableViewRowAction]? {
  
     let deleteAction = UITableViewRowAction(style: UITableViewRowActionStyle.Default, title: "Delete", handler: {
          (action : UITableViewRowAction, indexPath : NSIndexPath)  -&gt; Void  in
  
          if let managedObjectContext = (UIApplication.sharedApplication().delegate as! AppDelegate).managedObjectContext{
              let restaurantToDelete = self.fetchResultController.objectAtIndexPath(indexPath) as! Restaurant
              managedObjectContext.deleteObject(restaurantToDelete)
  
              // Saving managedObjectContext instance, and catch errors if it fails
              do {
                  try managedObjectContext.save()
              } catch let error as NSError {
                  print("Error: \(error.localizedDescription)")
              }
  
          }
  
      })
      return deleteAction
  }
  </code></pre>
  
  <p>the error message from Xcode is : Invalid conversion from throwing function of type '(UITableViewRowAction, NSIndexPath) throws -> Void' to non-throwing function type '(UITableViewRowAction, NSIndexPath) -> Void'</p>
  
  <p>I know the problem is managedObjectContext.save() will throw errors and this is not allowed in the completion handler. I found some blog articles where they modified the closure parameters in order to make the error handling in a closure workable. While here the definition of the function is given by apple, so how can i fix this issue? Thanks a lot! :D</p>