Enumeration
TorError
Canonical error surface for every swift-tor failure mode.
enum TorError
Mentioned In
Overview
TorError consolidates every expected failure across the embedded Tor process lifecycle, the control protocol, onion-service management, and low-level I/O into a single Sendable/Hashable enum — callers can switch exhaustively in one place instead of catching heterogeneous Error conformers from Foundation, POSIX, and the control layer. Associated-value payloads are String (or a (code: Int, message: String) tuple) so the concrete details of each failure are carried through without requiring downstream code to know the underlying machinery.
Cases are grouped by concern: Lifecycle covers TorError.alreadyStarted, TorError.notStarted, and TorError.startFailed(_:); Control protocol covers TorError.controlUnavailable, TorError.controlAuthFailed(_:), and TorError.controlProtocolError(code:message:); Onion service covers TorError.invalidServiceID(_:) and TorError.serviceAlreadyExists(_:); and General covers TorError.timeout, TorError.invalidResponse(_:), TorError.ioError(_:), and TorError.resourceExhausted(_:).
Note
Conformance is Error + Sendable + Hashable + CustomStringConvertible. Hashable is synthesised via SE-0185 across structural payloads, so two errors are equal iff both their cases and their associated strings/codes match verbatim.
Important
TorError does not yet conform to LocalizedError. Apple UI code that expects error.localizedDescription will fall back to the case name, not the human-readable description. Bridge explicitly via "\(error)" when rendering for users.
Topics
Lifecycle
Control protocol
Onion services
General
Rendering