Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swift: no calls to throwing functions occur within 'try' expression

I'm trying process string and set "try"

var str = String()
do{
    let str = try self.processMyString(strToProcess)

}catch{

}

But I'm getting this error:

no calls to throwing functions occur within 'try' expression

Any of you knows why of this error or how can I fix it?

I'll really appreciate your help.

like image 499
user2924482 Avatar asked Nov 18 '16 23:11

user2924482


Video Answer


1 Answers

If your function can cause errors, define it like this

func canThrowErrors() throws -> String 

like found here

Then you can use the try like you did already.

like image 103
transistor Avatar answered Sep 27 '22 20:09

transistor