Problem Statement
Explain how error handling works in Swift with `throw`, `try`, `catch` and how you would define a custom error.
Explanation
In Swift you define an `enum` (or `struct`/`class`) that conforms to the `Error` protocol to represent error types. /n/n Functions or methods that can throw must be marked with `throws`. When calling such a function you use `try`, and you wrap calls inside a `do { … } catch { … }` block to handle errors. /n/n You can also use `try?` to get an optional result or `try!` if you are certain there will be no error (though risky). For example: `enum FileError: Error { case notFound case unreadable } func readFile(path: String) throws -> String { … } do { let text = try readFile(path: path) } catch FileError.notFound { … } catch { … }`. This mechanism ensures that error-handling is explicit and safe.