If I have two functions A()
and B()
where A
calls B
. Now if an exception is thrown inside B
why can't I easily catch it inside A
using a try catch block in A
.
func B () -> Void {
// library code that triggers an unhandled fatal exception
}
func A () -> Void {
do {
try B()
} catch {
print(error)
}
}
This is something very easily done in other languages such as Java/Scala/Javascript etc.