[swift-evolution] Pitch: [stdlib] Error recovery hook, PR #12025
John Holdsworth
mac at johnholdsworth.com
Thu Sep 21 02:13:55 CDT 2017
Hi S/E,
I’ve raised a rather speculative PR suggesting a hook be added to stdlib
that would allow users to experiment with error recovery in their apps.
I’ve been asked to put it forward on Swift Evolution to gather opinions
from the wider community about such a design.
https://github.com/apple/swift/pull/12025 <https://github.com/apple/swift/pull/12025>
Ultimately, it comes down to being able to do something like this:
do {
try Fortify.exec {
var a: String!
a = a!
}
}
catch {
NSLog("Caught exception: \(error)")
}
This was primarily intended for user in "Swift on the server" but could also
help avoid crashes in the mobile domain. The rationale and mechanics
are written up at the following url:
http://johnholdsworth.com/fortify.html <http://johnholdsworth.com/fortify.html>
I'll accept this won’t be everybody’s cup of tea but at this stage this is
only an opt-in facilitating patch. Developers need not subject their apps
to this approach which requires a separate experimental implementation.
The recovery is reasonably well behaved except it will not recover
objects and system resources used in intermediate frames, It’s not
as random as something like, for example, trying to cancel a thread.
The debate about whether apps should try to soldier on when something
is clearly amiss is a stylistic one about which there will be a spectrum of
opinions. The arguments weigh more in favour in the server domain.
Over to you,
John
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170921/bb782e24/attachment.html>
More information about the swift-evolution
mailing list