It seems that Swift 2.0 has changed from traditional ObjC (NSError returning) and Swift 1.X (Success/Failure optionals) conventions of runtime error handling, to something that looks very similar to exception handling in languages like Java/C#/C++/etc.
Apple has traditionally emphasized use of NSError
instead of throwing NSException for runtime errors
(vs programmer errors), as NSException
stack unwinding could cause memory leaks with default ObjC compiler settings.
Now they have however devised something that looks very, very similar to traditional exceptions. My question is:
Are there any real differences between Swift 2.0 error handling and traditional exception handling beside nomenclature (error vs exception) and syntax (do-catch, instead of try-catch, try used before method call, etc).
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…