Functions
The following functions are available globally.
-
Unwraps the given optional, and throws an exception if the optional is nil.
Declaration
Swift
public func unwrap<T>(_ optional: T?) throws -> T
-
Compares two error objects. Allows the comparison of different Error enums or an Error protocol and a specific Error enum.
This is useful when catching exceptions of a specific Exception subclass and a specific underlying Error.
catch let error as Exception where error.error == ValueError.invalidArgument
Declaration
Swift
public func == <T>(lhs: Error, rhs: T) -> Bool where T : Equatable, T : Error
Parameters
lhs
An error to compare with.
rhs
An error to compare to. Must be equatable.
Return Value
true
if the errors are equal,false
otherwise.