Error handling
I am quite new to VBA programming and I have come across a problem when
dealing with errors. Comming from a C++ background I am most familiar with exceptions and I was wondering if there is some way to "rethrow" an erro once it has been handled? Something like: Sub Foo() On Error GoTo E: Bar Baz Exit Sub E: If Err.Number = 11 Then Resume Next Else ReThrow Err End If End Sub Imagine for example that sometimes Bar will try to divide by zero, and if that happens it is safe to resume and execute Baz. But if some other kind of error should happen I do not want to handle it here. I know that I can use 'Error Err.Number' or Err.Raise to "create" a new error in the else-block, but while developing it would be nice to have the original error to simplify debugging (since the debugger can show me where the error occurred). -- Erik Wikström |
All times are GMT +1. The time now is 12:00 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com