C++ exceptions vs Swift errors

Is there a write up somewhere as to why the error handling model in Swift is the way it is? Specifically I'm interested in why it was chosen over the C++ model. Was it simply to interoperate with Objective-C, or are there other advantages? I heard that C++ exceptions didn't quite succeed in terms of "don't pay for what you don't use", because of all the extra code that needs to be generated. Maybe Swift errors are better in that regard.

@John_McCall did a good exhaustive one way back when Error was first being added:


Very insightful article, thank you for the link.

The terminology's shifted a bit from then and now e.g. what's referred to as "typed propagation" in the article is what we already have (and sometime call "untyped throws"), and the currently discussed typed throws correspond to "Error Types" in the article.

1 Like