Trapping Save() Errors


Author
Message
choyt
choyt
StrataFrame User (132 reputation)StrataFrame User (132 reputation)StrataFrame User (132 reputation)StrataFrame User (132 reputation)StrataFrame User (132 reputation)StrataFrame User (132 reputation)StrataFrame User (132 reputation)StrataFrame User (132 reputation)StrataFrame User (132 reputation)
Group: Forum Members
Posts: 78, Visits: 246
Hi Folks

I am currently doing something similar to the following on every save() I do.

Select Case Me.Save

Case MicroFour.StrataFrame.Data.SaveUndoResult.AbortedWithBrokenRules

Throw New BrokenRulesException(Me.BrokenRules)

Case MicroFour.StrataFrame.Data.SaveUndoResult.FailedWithExceptions

Throw New ApplicationException("The save failed.")

End Select

I trap for broken rules and bubble them up with one custom exception class, and throw exceptions for the other results. Because of this I wind up with an ugly Case statement for every save. Is there any reason not to move this logic to the ErrorSaving event of the business object's themselves to centralize this or is this just the best way to do it?

Thanks!

Clay


Reply
StrataFrame Team
S
StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
Well, the ErrorSaving event only catches exceptions that are caused during the save, and only if the ErrorSavingMode is set to ContinueOnError.  Your best bet would be to create a BoBase class and override the OnBusinessRulesChecked method.  If the business rules are broken, then throw your exception containing the business rules. 

Another option would be to create the BoBase class and override Save().  Call MyBase.Save() and check the return value within your own Save() and check the select case there.  You could even show your form with the broken rules there if you don't mind taking that portion of the UI out of the UI...

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...





Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search