Pregunta

What happens when a Exception is raised on a Try-Finally block (without catch) and another exception is raised on the Finally part?

Example:

Dim aux As String

Try
    Try
        aux.Split("."c)
    Finally
        aux = File.ReadAllText("")
    End Try
Catch ex As Exception
    Console.WriteLine(ex)
End Try
¿Fue útil?

Solución

The last thrown exception is catched.

In this case, the ArgumentException from ReadAllText() on the Finally block. Ignoring the first exception being thrown.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top