I want to make a Swift Error
that describes how the Type
of a variable coming from Objective-C was wrong. Here's how I tried to define the struct
:
public struct UnexpectedResultTypeError<Expected, Actual>: Error {
let expected: Expected.Type
let actual: Actual.Type
init(expected: Expected.Type, got actual: Actual.Type) {
self.expected = expected
self.actual = actual
}
}
I figured that was fine, but now I can't initialize it:
UnexpectedResultTypeError<String, Any>(expected: String.self, got: type(of: serializedResult))
Cannot invoke initializer for type 'UnexpectedResultTypeError<String, Any>' with an argument list of type '(expected: String.Type, got: Any.Type)'