> ## Documentation Index
> Fetch the complete documentation index at: https://docs.clickterm.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Results & errors

> Handle ClickTerm iOS SDK results, cancellation, and errors with Swift concurrency.

The iOS SDK uses `async`/`await` instead of listener callbacks. Successful calls return their result directly; failures throw an error.

## Handle a dialog result

```swift theme={null}
Task { @MainActor in
    do {
        let signature = try await ClicktermDialog.show(
            from: self,
            request: request
        )

        guard let signature else {
            // The user already acted on this agreement.
            return
        }

        // Send the Signature to your backend for verification.
        await verifyOnYourBackend(signature)
    } catch ClicktermError.userCancelled {
        // The user dismissed the dialog without accepting or declining.
    } catch let error as ClicktermError {
        print(error.localizedDescription)
    } catch {
        print(error.localizedDescription)
    }
}
```

## ClicktermError

| Error                               | Meaning                                       |
| ----------------------------------- | --------------------------------------------- |
| `.notInitialized`                   | `ClicktermClient.initialize()` was not called |
| `.invalidArgument(message)`         | A required request value is empty or invalid  |
| `.network(underlying:)`             | The request could not reach the ClickTerm API |
| `.httpFailure(statusCode:message:)` | The API returned an unsuccessful response     |
| `.decoding(underlying:)`            | The SDK could not read the API response       |
| `.userCancelled`                    | The user dismissed the agreement dialog       |
| `.unknown(message)`                 | The SDK received an unexpected result         |

Handle specific failures with a `switch`:

```swift theme={null}
do {
    _ = try await ClicktermDialog.show(from: self, request: request)
} catch let error as ClicktermError {
    switch error {
    case .userCancelled:
        break
    case .notInitialized:
        assertionFailure("Initialize ClickTerm before showing a dialog.")
    case .httpFailure(let statusCode, let message):
        print("ClickTerm returned \(statusCode): \(message ?? "No details")")
    case .network(let underlying):
        print("Network problem: \(underlying.localizedDescription)")
    default:
        print(error.localizedDescription)
    }
}
```

<Note>
  A non-null Signature is still untrusted client input until your backend
  verifies it with the ClickTerm API.
</Note>
