How could a function throw multiple exceptions? For instance in Java would be something like this:
private Int f(Int data, boolean e)
throws AException, BException,
CException {...
Thanks
How could a function throw multiple exceptions? For instance in Java would be something like this:
private Int f(Int data, boolean e)
throws AException, BException,
CException {...
Thanks
The language does not supports that, most likely because it is considered an anti-pattern. However with a bit of ingenuity you can have an error case that takes an array of errors:
enum MyError: Error {
case general
case notFound
case invalid
case multiple([MyError])
}
func test() throws {
throw MyError.multiple([.general, .invalid])
}