title: Returning value for function that throws
body: <p>I've got a pretty simple question but I could only find a similar answer in C++ thread. Compiler complains on <code>getUserFromServer</code> function stating that it requires <code>return</code> value even though it can catch an exception. It is obvious WHY it asks for return value but I'm not sure how to handle the situation properly. </p>
  
  <p>One way is to create some sort of dummy <code>user</code> and return it but it doesn't sound any good. Another way is by making return type <code>Optional</code> but it's just moving responsibility for nil-checks to another level, which is probably not a good idea. Any help would help.</p>
  
  <p>Here's a setup to simulate behaviour I expect in real code.</p>
  
  <pre><code>enum TestError: Error {
      case JustError
  }
  
  class User {}
  class ServerClient {
      func getUser(really: Bool) throws -&gt; User {
          var uza: User?
          if really {
              uza = User()
          }
          guard let user = uza else {
              throw TestError.JustError
          }
          return user
      }
  }
  
  func getUserFromServer() -&gt; User {
  
      let client = ServerClient()
      let user: User
  
      do {
          user = try client.getUser(really: true)
          return user
      } catch TestError.JustError {
          print("just an error occured")
      } catch {
          print("something terrible happened")
      }
  } //Error: missing return in a function
  </code></pre>