title: Swift Combine return Publisher from func
body: <p>I want to return the publisher for a function if there is error in input params for it but its giving some compilation error.</p>
  <p>Below is the function for the same.</p>
  <pre><code>func fetchList(input: String) -&gt; AnyPublisher&lt;List, Error&gt; {
      guard let url = URL(string: input)  else {            
          return AnyPublisher(URLError(.cannotParseResponse))
      }
      //some call for to get the List which returns publisher
  }
  </code></pre>
  <p><strong>Error</strong></p>
  <p><code>Cannot invoke initializer for type 'AnyPublisher&lt;_, _&gt;' with an argument list of type '(URLError)'</code></p>
  <p><strong>Summary</strong></p>
  <p>How to create our publisher to return the error?</p>
  <p>Thanks for any hint in the right direction.</p>