Why catch an exception just to throw it again?

In a webservice I see this code:

<WebMethod()> _
Public Function dosomething() As Boolean
        If successful Then
            Return True
            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.


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.

Don't do this.

If you absolutely need to rethrow the exception, just use throw; using throw ex; erases the stack trace and is absolutely wrong.

Need Your Help

Stored procedure in oracle sql

sql oracle stored-procedures

I'm trying to do a very simple stored procedure for a class project. I just want to use it to execute a simple insert statement.

How to use variables in SQL Reporting 2008 R2

sql sql-server-2008-r2

I want to populate a combo box with a list of dates from a DB. Then based on user input I want to be change the Tablix to filter on only dates later than the selected date.