title: implementing swift's new try catch with older tutorial on connecting with my sql
body: <p>Hi I'm struggling with implementing swifts new try catch with an older tutorial on connecting to a mysql database.</p>
  
  <p>Here is the older tutorial's code:</p>
  
  <pre><code>func getPost(callback:(NSDictionary) -&gt; ()){
      request("http://myurl.php", callback: callback)
  }
  
  func request(url:String, callback:(NSDictionary) -&gt; ()){
      var nsURL = NSURL(string: url)
  
      let task = NSURLSession.sharedSession().dataTaskWithURL(nsURL!){
          (data, response, error) in
          var error:NSError?
          var response = NSJSONSerialization.JSONObjectWithData(data!, options: NSJSONReadingOptions.MutableContainers) as NSDictionary
          callback(response)
      }
      task.resume()
  }
  </code></pre>
  
  <p>Here is my failing attempt to implement the try catch since it wants that instead of error in the response var</p>
  
  <pre><code>func getPost(callback:(NSDictionary) -&gt; ()){
      request("http://url.php", callback: callback)
  }
  
  func request(url:String, callback:(NSDictionary) -&gt; ()){
      var nsURL = NSURL(string: url)
  
      let task = NSURLSession.sharedSession().dataTaskWithURL(nsURL!){
          (data, response, error) in
  
          do {
              var response = try NSJSONSerialization.JSONObjectWithData(data, options: NSJSONReadingOptions.MutableContainers) as! NSDictionary
              callback(response)
          } catch error&amp; {
  
          }
  
  
  
      }
      task.resume()
  }
  </code></pre>
  
  <p>Id really appreciate someone helping with getting the syntax right, thanks!</p>
  
  <p><strong>complete working code:</strong></p>
  
  <pre><code>func getFleet(){
      getPost{
          (response) in
          print(response)
      }
  }
  
  func getPost(callback:(NSDictionary) -&gt; ()){
      request("http://url.com/SpaceAcademy/SaveFleet.php", callback: callback)
  }
  
  func request(url:String, callback:(NSDictionary) -&gt; ()){
      let nsURL = NSURL(string: url)
  
      let task = NSURLSession.sharedSession().dataTaskWithURL(nsURL!) { (data, nsURLResponse, error) -&gt; Void in
          if let error = error {
              //act on error from server
          } else {
              do {
                  var response = try NSJSONSerialization.JSONObjectWithData(data!, options: NSJSONReadingOptions.MutableContainers) as! NSDictionary
                  callback(response)
              } catch {
                  // act on thrown error
              }
          }
      }
      task.resume()
  }
  </code></pre>