What is the proper way to throw an error from a function like this:
func fetch(by id: String, page: Int = 1) -> Promise<ProductReviewBase> {
// call api
guard let url = URL(string: "") else {
return Promise { _ in return IntegrationError.invalidURL }
}
return query(with: url)
}
I'm confused whether to make this a function that throws an error, or return a promise that returns an error. Thanks