title: Try-catch like feature for uncertain code block in Swift 4
body: <p>I am writing a test in XCUITest. There is an introductory banner which may or may not come on the mobile screen while my test is in progress. I want to write my case in such a way that, if the banner is present, I have to verify certain elements on that banner and click on the "Continue" button on it, and if it is not present, I have to proceed with my test case. </p>
  
  <p>I know in Java, we write such code inside a try-catch block, so that even if the banner is not found and the code fails, the pointer goes into the catch block and the remaining program continues.</p>
  
  <p>When I searched on the internet, i only found such feature for single statements and not for some chunk of code block.Do we have something similar in Swift, where I can write some code inside try-catch like code block?
  Please have a look at my test case and the code to click in the banner.</p>
  
  <pre><code>class MyTestClass: BaseTest {
      func testMapSearch() {
          do {
              let app = try XCUIApplication()
              let element = try app.children(matching: .window).element(boundBy: 0).children(matching: .other).element.children(matching: .other).element(boundBy: 1).children(matching: .other).element(boundBy: 0)
              element.buttons["Continue"].tap()
          } catch let error {
              print("Error: \(error)")
          }
  
          let logInButton = app.scrollViews.otherElements.buttons["Log In"]
  
          checkLoginPage(login: logInButton)
          logInButton.tap()
      }
  }
  </code></pre>
  
  <p>The <code>do</code> block is written to click on the "Continue" button on a banner which is not sure to be displayed on the screen. The <code>do</code> block is followed by more code. If the banner is not displayed, the code written in the <code>do</code> block fails and the test case throws an error. I want to write a case such that the login button code should get executed irrespective of the banner is displayed or not. </p>