Search code examples
iosswiftparse-platform

Parse iOS - How to capture the findObjects() error being thrown?


I am coding in Swift and attempting to use the findObjects() function for the Parse iOS SDK. However, I can't seem to figure out what type of error is being thrown by Parse if this function call fails. I'm a novice in Swift so that may be my issue. I attempt to call the function in a do->catch block and use the try keyword on the function call however I'm not sure what to catch. I can catch the error using the _ but I would like to grab the description from the error. Thanks!

P.S. I don't want to use the findObjectsInBackground() method.

do {
    let object = try query.getFirstObject()
    // do something with the object
} catch _ {
    // this is where I would like to print out the error description
}

Solution

  • In Obj-C, which I assume will be similar, I print out the error.userInfo[@"error"] parameter of the NSError that is returned.