The problem is what Typeis the Swift keyword, and your custom one is Typeconfused by the compiler.
In my tests on the playground, your code generated the same error. The solution is to change Typefor any other name. Example with Kind:
public enum Kind: Int {
case ConnectionError
case ServerError
}
init(type: Kind) {
super.init(domain: "domain", code: type.rawValue, userInfo: [:])
}
Then
MyError.Kind.ConnectionError.rawValue
works as expected.
source
share