(Also posted in the Swift forum: Bridging to NSError fails for instances of a class.)
According to SE-0112, every type that conforms to the Error protocol is implicitly bridged to NSError. This does not work with reference types, the last line in the following example does not compile:
Inserting an “intermediate cast” to `Error` makes it compile and run as expected:
That problem occurs only if the custom error type is a class, not with a struct or an enum.