【发布时间】:2020-10-13 01:00:07
【问题描述】:
如果函数的输入参数有错误但它给出了一些编译错误,我想返回发布者。
下面是相同的功能。
func fetchList(input: String) -> AnyPublisher<List, Error> {
guard let url = URL(string: input) else {
return AnyPublisher(URLError(.cannotParseResponse))
}
//some call for to get the List which returns publisher
}
错误
Cannot invoke initializer for type 'AnyPublisher<_, _>' with an argument list of type '(URLError)'
总结
如何创建我们的发布者返回错误?
感谢您提供正确方向的任何提示。
【问题讨论】: