Search code examples
vb.netweb-servicesexception

Why catch an exception just to throw it again?


In a webservice I see this code:

<WebMethod()> _
Public Function dosomething() As Boolean
    Try
        If successful Then
            Return True
        Else
            Return False
        End If
    Catch ex As Exception
        Throw ex
    End Try
End Function

What's the point of catching the exception and just throwing it again? Do I miss something?

Edit: Thanks for the answers! I thought it was something like that, but wasn't sure if I could/would refactor those away without any implications.


Solution

  • I can think of no reason to do this for functionality. However, it can arise when previously there was some error handling (logging usually) that has been removed, and the developer removed the log handling but did not restructure the code to remove the redundant try/catch.