Avatar
できた import SceneKit public func recover <R> (_ f: () throws -> R, ifError: (Error) -> Optional<R>) -> Optional<R> { do { return try f() } catch let error { return ifError(error) } } func test() { let url = URL(fileURLWithPath: "http://www.google.com") guard let _ = recover({ () -> SCNScene in try SCNScene(url: url) }, ifError: { error in print(error) return nil }) else { return } } (edited)