DDMathParser icon indicating copy to clipboard operation
DDMathParser copied to clipboard

Errors Thrown from here are not handled

Open shaqaruden opened this issue 9 years ago • 3 comments

I'm trying to use DDMathParser in its simplest form of the copy and pasting the code provided in the Wiki and i get the error that is in the title of this issue for this code.

let value = try "1 + 2".evaluate()

Im using Xcode 7 with Swift 2 and installed DDMathParser with CocoaPods.

shaqaruden avatar Sep 22 '15 06:09 shaqaruden

As mentioned on the Errors wiki page, you need to perform this within a do ... catch block.

I'll leave this open as a request to expand the wiki article on how to effectively deal with errors.

davedelong avatar Sep 22 '15 14:09 davedelong

but where the right way example? i create a new blank project anh write the first example code is let value = try "1 + 2".evaluate() and get this error? please help for begining useer! Thank you so much!

kanjizu avatar Dec 04 '15 03:12 kanjizu

@kanjizu Im not sure why he is not putting fully working code in the Documentation but here is what you need to do.

do {
    let value = try "1 + 2".evaluate() 
} catch {
    print(error)
}

shaqaruden avatar Sep 23 '16 07:09 shaqaruden