Skip to content

Commit defbe66

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(). (cherry picked from commit d583377)
1 parent 843e92a commit defbe66

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
@@ -28,7 +28,7 @@ open class FileHandle : NSObject, NSSecureCoding {
2828
let readResult = try _readDataOfLength(Int.max, untilEOF: false)
2929
return readResult.toData()
3030
} catch {
31-
return Data()
31+
fatalError("\(error)")
3232
}
3333
}
3434

@@ -41,7 +41,7 @@ open class FileHandle : NSObject, NSSecureCoding {
4141
let readResult = try _readDataOfLength(length, untilEOF: true)
4242
return readResult.toData()
4343
} catch {
44-
return Data()
44+
fatalError("\(error)")
4545
}
4646
}
4747

0 commit comments

Comments
 (0)