Capturing errors

Capturing errors

SRSDS
Advisor Advisor
492 Views
1 Reply
Message 1 of 2

Capturing errors

SRSDS
Advisor
Advisor

I’ve obviously taken the wrong approach to this and need some help. 10 years of what I thought was a sensible approach has been turned on its head.

Using trans As Transaction = Application.DocumentManager.MdiActiveDocument.TransactionManager.StartTransaction : trcnt += 1 : LastOpenedTransaction = Reflection.MethodBase.GetCurrentMethod.Name()
      MySub(trans)
      trans.Commit() : trcnt -= 1 : If trcnt > 0 Then : MsgBox("TRCNT>0" & vbCr & "Last opened transaction in " & LastOpenedTransaction) : LastOpenedTransaction = "" : End If
End Using

This monitored if all the transactions opened had been closed as well as reporting on which last transaction failed.

Feels like a bug but, I recently discovered that this method doesn’t allow me to undo all the operations committed under one undo command.

 

If I now need to add transactions to each subroutine, how do I now monitor failures?

If a coding error occurred the try..catch often didn’t catch anything so my tactic was to create a master transaction, pass that transaction to each subroutine, and monitor that.

Accepted solutions (1)
493 Views
1 Reply
Reply (1)
Message 2 of 2

SRSDS
Advisor
Advisor
Accepted solution

I've just realised that what I have is probably ok.

It was only relatively recently that I added the LastOpenedTransaction variable which will now capture which last subroutine failed.

 

Prior to that I was an annoying game trying to figure out why trcnt (the transaction count) failed to return to 1.

 

Sorry. Think I've just answered my own question. 

0 Likes