[swift-evolution] do try catch?

Don Arnel dmarnel at gmail.com
Mon Dec 7 08:30:36 CST 2015


Is there a reason this format was adopted for error handling:

do {
    try makeASandwich()
    eatASandwich()
} catch Error.OutOfCleanDishes {
    washDishes()
} catch Error.MissingIngredients(let ingredients) {
    buyGroceries(ingredients)
}

rather than this format:

try {
    makeASandwich()
    eatASandwich()
} catch Error.OutOfCleanDishes {
    washDishes()
} catch Error.MissingIngredients(let ingredients) {
    buyGroceries(ingredients)
}

The second format is much more intuitive, and reads easier IMO.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20151207/7f3b839b/attachment.html>


More information about the swift-evolution mailing list