Skip to content

Commit d583377

Browse files
committed
SR-8999: Ensure the FileHandle read methods call fatalError() on error
- readDataToEndOfFile(), readData(ofLength length: Int) and .availableData should call fataError() if there are IO errors, not return an empty Data().
1 parent 5733313 commit d583377

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Foundation/FileHandle.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ open class FileHandle : NSObject, NSSecureCoding {
3535
let readResult = try _readDataOfLength(Int.max, untilEOF: false)
3636
return readResult.toData()
3737
} catch {
38-
return Data()
38+
fatalError("\(error)")
3939
}
4040
}
4141

@@ -48,7 +48,7 @@ open class FileHandle : NSObject, NSSecureCoding {
4848
let readResult = try _readDataOfLength(length, untilEOF: true)
4949
return readResult.toData()
5050
} catch {
51-
return Data()
51+
fatalError("\(error)")
5252
}
5353
}
5454

0 commit comments

Comments
 (0)