Search code examples
swiftswift5

I want my custom Error type has name "Error"


Not "MyError" or with any other prefixes or suffixes. I want it to be just "Error". Because when I refer this type in the code it would be like: MyApp.Error. Nice and simple.

enum MyApp {
    enum SomeModel {}
    enum OneMoreModel {}
    enum Error: Error {
        
    }
}

It does't compile:

'Error' has a raw type that depends on itself

I tried Error: swift.Error but

Cannot find type 'swift' in scope

What else can I try?


Solution

  • The name of the module is Swift, with a capital "S".

    enum Error: Swift.Error {
        
    }