FileHandle un-catchable exceptions in Swift Bridged API

Originator:aaroncrespo
Number:rdar://30537361 Date Originated:2/15/2017
Status:Open Resolved:
Product:Xcode Product Version:7 8.1 8.2 8.3
Classification:Crash Reproducible:Yes
 
Area:
Xcode

Summary:
NSFileHandle and bridged FileHandle uses exceptions for error handling. Currently in swift there is no faculty to catch from of these recoverable/un recoverable conditions

Steps to Reproduce:
1 use Filehandle API
2 use Filehandle API incorrectly or have an error condition occur (full disk, exhaust file descriptors etc

~~~
FileManager.default.createFile(atPath: "test", contents: nil, attributes: nil)
let handle = FileHandle(forWritingAtPath: "test")!

handle.closeFile()
handle.availableData
~~~

Expected Results:
expect to be able to catch and respond to errors. either crash gracefully in unrecoverable conditions or prevent crashes in recoverable conditions. 

Actual Results:
code crashes due to uncaught exception

Version:
10.12.3 (16D32)

Notes:


Configuration:
Any Swift + Foundation combination with FileHandle API

Xcode 7
Xcode 8.2
Xcode 8.3

Attachments:
'Test.playground.zip' was successfully uploaded.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!