i have an error type that wraps another existential any Error
:
@frozen public
struct RecursiveError<Location>:Error
{
/// The location (key or index) where the error occurred.
public
let location:Location
/// The underlying error that occurred.
public
let error:any Error
@inlinable public
init(_ error:any Error, in location:Location)
{
self.location = location
self.error = error
}
}
now i want to test if my API is throwing the correct error with a unit test like:
$0.test(name: "int32-to-uint8", decoding: bson,
failure: RecursiveError<String>.init(
IntegerOverflowError<UInt8>.int32(.max),
in: "int32"))
{
try $0["int32"].decode(to: UInt8.self)
}
but that would require RecursiveError
to be Equatable
. and making RecursiveError
Equatable
requires comparing two any Error
existentials. is there a way to do this?