Exception handling for database


Author
Message
John Frankewicz
John Frankewicz
StrataFrame Beginner (40 reputation)StrataFrame Beginner (40 reputation)StrataFrame Beginner (40 reputation)StrataFrame Beginner (40 reputation)StrataFrame Beginner (40 reputation)StrataFrame Beginner (40 reputation)StrataFrame Beginner (40 reputation)StrataFrame Beginner (40 reputation)StrataFrame Beginner (40 reputation)
Group: Forum Members
Posts: 36, Visits: 65
What do you suggest is the appropriate place to trap exceptions that my occur as a result of a database error?
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
The best place to catch a database exception is around the Save() call on the business object, or the Save() call on a form.



Basically, you have two options:



1) Set the ErrorSavingMode property on the business object to FailOnError (default) and the business object will bubble up the exceptions from the saving theads. All of the saving threads will abort, causing the rest of the save to fail. (Whether or not the changes on the rows that have already been saved successfully are accepted depends upon the AcceptRowChangesMode.)



2) Set the ErrorSavingMode property on the business object to ContinueOnError and the business object will catch all of the saving exceptions (including the concurrency exceptions). Then it will report the errors to you by doing 3 things:

a) Set the DataRows in error that did not save properly.

b) Collect the save errors and add them to the SaveErrors property on a new DataLayerSavingException.

c) Raise the ErrorSaving event giving you the DataLayerSavingException containing all of the errors (rather than throwing the DataLayerSavingException), including the retrieved server rows for comparision on concurrency exceptions.



So, the FailOnError goes boom if you get an exception while saving, aborts all threads, and throws you the exception. ContinueOnError provides the exception(s) in the ErrorSaving event after the save has completed and all rows that could possibly be saved are saved.

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