title: How to add throw in the network operation workflow
body: <p>I have the following implementation, and having difficulties to throws if there any issues happen during the following workflow. As you see in my code, I either return nil or does not return anything, wondering how to handle these scenario.</p>
  <pre><code>enum ContentServiceError: Error {
    case EncodingError
    case URLInvalidError
  }
  
  DispatchQueue.global(qos: .background).async {
    postContent(id: id, content: content) { (error) in
      DispatchQueue.main.async { [weak self] in
          // handle throw here
      }
    }
  }
  
  func postContent(
      id: String?,
      content: String,
      completion: @escaping(Error?) -&gt; ()
    ) {
      guard
        let id = id,
        let url =  URL(string: &quot;\(baseURL)\(contentEndPoint)\(id)&quot;),
        let contentData = contentData(from: Content(id: id, content: content)),
      else {
        // how to add throw here
        return
      }
      let request = Request(headers: nil, httpMethod: .post, httpBody: contentData, parameters: nil, url: url)
      let networkHandler = NetworkHandler(urlSession: URLSession(configuration: URLSessionConfiguration.ephemeral))
      networkHandler.dataRequest(request, successHandler: { data in
        completion(nil)
      }, failureHandler: { error in
        completion(error)
      })
    }
  
  
   private func contentData(content: Content) -&gt; Data? {
      var content: Data
      do {
        let encoder = JSONEncoder()
        contentData = try encoder.encode(content)
      } catch {
        // how to add throw here 
        return nil
      }
      return contentData
    }
  </code></pre>