StrataFrame Forum

Trap Save Error and respond with a message box

http://forum.strataframe.net/Topic12927.aspx

By Mike Rogers - 12/6/2007

Hi

I am trying to trap a save error   for example  instead of StrataFrame responding with its own error box for having a duplicate record. I would like to trap this and display my own message box notifying the user what is needed to be able to save.

I tried to use this code in the business object without any success.  I put a break point to see if it stops and it does not. Please tell me where I am going wrong. 

Thanks

Public Overrides Function Save(ByVal b As Boolean) As MicroFour.StrataFrame.Data.SaveUndoResult

Dim r As MicroFour.StrataFrame.Data.SaveUndoResult

r = MyBase.Save(b)

Throw New ApplicationException()

End Select

End If

End Function

By Mike Rogers - 12/6/2007

I add a event to the tool bar of the form. Now I get the business object stepping thru the code.  But how do I turn off the Strata Frame error message now.
By StrataFrame Team - 12/7/2007

The reason the StrataFrame error is being shown is that the MyBase.Save() call is throwing an exception and you're not catching it, so it's being handled by the StrataFrameApplication object.

What you probably want to do is set the business object's ErrorSavingMode to ContinueOnError (it defaults to FailOnError and throws exceptions when saving).  That way, you could handle the ErrorSaving event on the business object and show your message inside of that event handler.

The other option would be to wrap the MyBase.Save() call in your overriden method with a Try/Catch.  In the Catch, show your message.