title: What are the differences between throws and rethrows in Swift?
body: <p>After searching for some references to figure it out, -unfortunately- I could not find useful -and simple- description about understanding the differences between <code>throws</code> and <code>rethrows</code>. It is kind of confusing when try to understand how we should use them.</p>
  
  <p>I would mention that I am kind of familiar with the -default- <code>throws</code> with its simplest form for propagating an error, as follows:</p>
  
  <pre><code>enum CustomError: Error {
      case potato
      case tomato
  }
  
  func throwCustomError(_ string: String) throws {
      if string.lowercased().trimmingCharacters(in: .whitespaces) == "potato" {
          throw CustomError.potato
      }
  
      if string.lowercased().trimmingCharacters(in: .whitespaces) == "tomato" {
          throw CustomError.tomato
      }
  }
  
  do {
      try throwCustomError("potato")
  } catch let error as CustomError {
      switch error {
      case .potato:
          print("potatos catched") // potatos catched
      case .tomato:
          print("tomato catched")
      }
  }
  </code></pre>
  
  <p>So far so good, but the problem arises when:</p>
  
  <pre><code>func throwCustomError(function:(String) throws -&gt; ()) throws {
      try function("throws string")
  }
  
  func rethrowCustomError(function:(String) throws -&gt; ()) rethrows {
      try function("rethrows string")
  }
  
  rethrowCustomError { string in
      print(string) // rethrows string
  }
  
  try throwCustomError { string in
      print(string) // throws string
  }
  </code></pre>
  
  <p>what I know so far is when calling a function that <code>throws</code> it has to be handled by a <code>try</code>, unlike the <code>rethrows</code>. So what?! What is logic that we should follow when deciding to use <code>throws</code> or <code>rethrows</code>?</p>