Skip to content

Commit

Permalink
Make it more resilient against API changes
Browse files Browse the repository at this point in the history
  • Loading branch information
m0ppers committed Apr 30, 2015
1 parent db07bf6 commit ebdbc84
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions syncthing-bar/SyncthingRunner.swift
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,20 @@ class SyncthingRunner: NSObject {

let request = createRequest("/rest/config")
NSURLConnection.sendAsynchronousRequest(request, queue: NSOperationQueue.mainQueue()) {(response, data, error) in
if (error != nil) {
println("Got error collecting repositories \(error)")
return;
}
let httpResponse = response as? NSHTTPURLResponse;
if httpResponse == nil {
println("Unexpected response");
return;
}

if httpResponse!.statusCode != 200 {
println("Got non 200 HTTP Response \(httpResponse!.statusCode)");
return;
}
if (error == nil) {
var jsonResult: NSDictionary = NSJSONSerialization.JSONObjectWithData(data, options: NSJSONReadingOptions.MutableContainers, error: nil) as! NSDictionary

Expand Down

0 comments on commit ebdbc84

Please sign in to comment.