title: How to make Swift detect an NSError subclass used by Objective-C methods?
body: <p>I am tidying up a large legacy Objective-C library for use inside a new Swift project.</p>
  
  <p>Now normally an Objective-C method like <code>-initWithContentsOfFile:encoding:error:(NSError*)err</code> gets turned into <code>init(contentsOfFile path: String, encoding enc: UInt) throws</code> on the Swift side.</p>
  
  <p>But in this legacy codebase we have a custom error subclass <code>@interface MyError : NSError</code>. This seems to break this automatic error conversion, so that a method like <code>-initWIthConfig:error:(MyError**)err</code> gets treated by Swift only as
  <code>init(config: [String:Any], error: AutoreleasingUnsafeMutablePointer&lt;MyError?&gt;)</code> — which is not useful!</p>
  
  <p>Now I see there is an <code>ErrorType</code> protocol on the Swift side but that does not seem relevant here. My own error type (<code>MyError</code>) already inherits from <code>NSError</code> and needs to stay that way on the Objective-C side.</p>
  
  <p>How do I get Swift to recognize my custom error subclass as an error type, so that it treats each method that uses it into one which <code>throws</code>? I am able to edit the legacy framework, but am not sure how I can annotate these methods for conversion.</p>