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 All

I wanted to add a little more detail to what I am trying to accomplish.

When performing Save(True) operations on multiple business objects at one time and one of the Save operations fail, I want to rollback the transaction then throw a specific exceptin as described below.

  1. When a save fails due to broken rules, I want to throw a custom exception containing these broken rules to the presentation layer (we are currently converting the broken rules collection to a JSON string and passing that string).
  2. When a save failes due to any other reason, I want to rethrow that exception up the chain
  3. When either of the above happen, I want to write either the exception or the broken rules to the application log. The idea is that our presentation tier validation should nearly eliminate broken rules from being written to the app log (I hope!).

I thought about overriding the Save() method and putting the logic there. I also thought about putting the logic in the Business Rules Checked event but I'm thinking that would miss straight out failures.

What I'm looking for is mostly an idea of what would be the best practice and maybe how others are doing this type of operation,. I hope this makes sense!

Clay


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


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