} remember, though, that if all the exceptions belong to the same class hierarchy, you can simply catch that base exception type Also note that you cannot catch both exceptiona and exceptionb in the same block if exceptionb is inherited, either directly or indirectly, from exceptiona I want to know if i can safely write catch () only to catch all system.exception types Or do i've to stick to catch (exception) to accomplish this I know for other exception types (e.g. Is there a way to catch both exceptions and only set webid = guid.empty once
The given example is rather simple, as it's only a guid, but imagine code where you modify an object multiple times, and if one of the manipulations fails as expected, you want to reset the object. I think that this only works if you raise and then catch the exception, but not if you try getting the traceback before raising an exception object that you create, which you might want to do in some designs. 13 nope, catch (or finally) is try 's friend and always there as part of try/catch However, it is perfectly valid to have them empty, like in your example In the comments in your example code (if func1 throws error, try func2), it would seem that what you really want to do is call the next function inside of the catch block of the previous. Please forgive my inability to paste the actual code, but what he did was something
I am trying to write an ms sql script that has a transaction and a try/catch block If it catches an exception, the transaction is rolled back If not, the transaction is committed
OPEN