SysDragon
SysDragon

Reputation: 9888

Exception from within a Finally on a Try-Finally block

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

Upvotes: 2

Views: 84

Answers (1)

SysDragon
SysDragon

Reputation: 9888

The last thrown exception is catched.

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

Upvotes: 3

Related Questions