P
Peter Duniho
Ganze said:I work with try/catch block. Since its a multy line method I would like to
know excatly what is the last command that passes succefully before going to
the catch block.
Define "command". Do you mean a program statement? An individual
operation or expression evaluation? Something else?
Is there some way to do it without embeding logger messages after every code
line?
Sure. But any solution will involve _something_ like that, such as
setting flags, keeping a counter, etc. There's nothing built in that
would tell you the last successful program statement.
However, note that you can get almost all the way there just by
inspecting the StackTrace in the exception object.
Because a single statement can include multiple operations and even
multiple method calls, and of course because an exception that occurs
inside a method call involves other code that has successfully executed
besides that which is found in your try/catch block, the StackTrace does
not give you a precise, per-operation information. But it will give you
the information down to the program statement, which may be enough for
your needs, depending on what exactly you actually mean by "command".
Pete