iosswiftswift2rawrepresentable

Swift 2.1 ErrorType does not conform protocol RawRepresentable


I have declared error type

enum UserServicesError: ErrorType {
    case UserNotLogged
}

but I get an error

Argument type 'UserServicesError' does not conform to expected type 'ErrorType'

Type 'UserServicesError' does not conform to protocol 'RawRepresentable'

Any idea y? Official documentation says that this declaration is sufficient.

Apple Swift 2.1 Error handling documentation


Solution

  • I've finally figure it out. I had declared enum ErrorType in objective-c shared class from pre-swift ages.

    typedef NS_ENUM(NSUInteger, ErrorType) {
       ...
    };
    

    I would expect to see a Redefined type error rather than does not conform to protocol 'RawRepresentable'