Skip to content
This repository was archived by the owner on Sep 19, 2024. It is now read-only.

Commit c922022

Browse files
committed
Fix optional and throwing initializer
1 parent 3fcd4b6 commit c922022

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Diff for: Library/Foundation/Data+FileResource.swift

+4-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
import Foundation
1010

11+
public struct NoUrlForResourceError: Error {}
12+
1113
public extension Data {
1214

1315
/**
@@ -17,8 +19,8 @@ public extension Data {
1719

1820
- returns: A NSData object with the contents of the specified file.
1921
*/
20-
public init?(resource: FileResourceType) throws {
21-
guard let url = resource.url() else { return nil }
22+
public init(resource: FileResourceType) throws {
23+
guard let url = resource.url() else { throw NoUrlForResourceError() }
2224
try self.init(contentsOf: url)
2325
}
2426
}

0 commit comments

Comments
 (0)