I made a stupid mistake this week
I made a stupid mistake this week that I submitted a merge request causing a model parsing error on production environment. I had written a function with a do-catch block in it but forgetting to write the catch
block only one do
block. Usually, the Xcode compiler will detect this missing and throws a compilation error. But that function is a throws
function that silenced the error.
The logic of the method is roughly as follows:
1 | func parse<T>(keys: [String]) throws -> T { |
The question is the else
block that has a do
block but doesn’t cache errors. It caused that subsequent keys didn’t be tried if the first key thrown an error.