title: Swift do-try-catch syntax
body: <p>I give it a try to understand new error handling thing in swift 2. Here is what I did: I first declared an error enum:</p>
  
  <pre><code>enum SandwichError: ErrorType {
      case NotMe
      case DoItYourself
  }
  </code></pre>
  
  <p>And then I declared a method that throws an error (not an exception folks. It is an error.). Here is that method:</p>
  
  <pre><code>func makeMeSandwich(names: [String: String]) throws -&gt; String {
      guard let sandwich = names["sandwich"] else {
          throw SandwichError.NotMe
      }
  
      return sandwich
  }
  </code></pre>
  
  <p>The problem is from the calling side. Here is the code that calls this method:</p>
  
  <pre><code>let kitchen = ["sandwich": "ready", "breakfeast": "not ready"]
  
  do {
      let sandwich = try makeMeSandwich(kitchen)
      print("i eat it \(sandwich)")
  } catch SandwichError.NotMe {
      print("Not me error")
  } catch SandwichError.DoItYourself {
      print("do it error")
  }
  </code></pre>
  
  <p>After the <code>do</code> line compiler says <code>Errors thrown from here are not handled because the enclosing catch is not exhaustive</code>. But in my opinion it is exhaustive because there is only two case in <code>SandwichError</code> enum. </p>
  
  <p>For regular switch statements swift can understands it is exhaustive when every case handled.</p>