I am new to Swift and I have a little problem.
I have a piece of code, and any line can potentially cause an error.
My problem is that I do not want to go line by line, catching every error, I want to catch them all in one expression.
In python you can do it
try: exampleArray = [1,2,3,4] print(exampleArray[4]) except Exception as e: print(e) pass
What this means is an attempt to print a value from an array that does not exist, but it falls into the except statement, I wonder if something like this is possible in Swift
To clarify, I'm not trying to catch the index out of range error, I just want to catch the error, regardless of what it is.
Is this possible without announcing my own mistakes and throwing them line by line?
source share