We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 3fcd4b6 commit c922022Copy full SHA for c922022
Library/Foundation/Data+FileResource.swift
@@ -8,6 +8,8 @@
8
9
import Foundation
10
11
+public struct NoUrlForResourceError: Error {}
12
+
13
public extension Data {
14
15
/**
@@ -17,8 +19,8 @@ public extension Data {
17
19
18
20
- returns: A NSData object with the contents of the specified file.
21
*/
- public init?(resource: FileResourceType) throws {
- guard let url = resource.url() else { return nil }
22
+ public init(resource: FileResourceType) throws {
23
+ guard let url = resource.url() else { throw NoUrlForResourceError() }
24
try self.init(contentsOf: url)
25
}
26
0 commit comments