Love it!
This seems like yet another great reason to also revive the guard
-catch
proposal. The ceremony that encourages grouping multiple try
statements in a do
block will be that much more harmful when it forces this error type erasure. This is much worse when the throwing expressions yield a value that you need in a later step:
do {
let filename = try lookUpFileName() // throws ConfigurationError
let data = try readFile(named: filename) // throws FileSystemError
let result = try processData(data) // throws DataProcessingError
} catch {
// any Error :(
}
(ETA: particularly in embedded Swift, where I assume the above do
block will yield a compilation error.)