Reputation: 10048
I'm learning swift by following the swift programming lanuguage 3.0 handbook. In the error handling chapter, when one want to declare an error type, you implement the ErrorProtocol
protocol. As shown below:
enum VendingMachineError: ErrorProtocol{
case invalidSelection
case insufficientFuns(coinsNeeded: Int)
case outOfStock
}
But in xcode playground, I keep getting the error message
1) use of undeclared type ErrorProtocol
2) type VendingMachineError does not conform to protocol RawRepresentable
Why is this happening? I'm simply coping the code from the book.
Upvotes: 0
Views: 190
Reputation: 9923
It's not ErrorProtocol
, it's ErrorType
, you declare that when creating error enum
Upvotes: 1