On Sun, Aug 2, 2009 at 3:56 PM, Ed Leafe<[email protected]> wrote: > On Aug 2, 2009, at 9:35 AM, Miguel Lopes wrote: > >>> Generally you want to catch errors in your saves, and when an >>> error >>> is encountered, rollback everything. Only if no errors occur do you >>> call commitTransaction. >> >> How can I catch errors in saves? >> I've checked the API and bizobj methods save() and saveAll() do not >> raise errors. > > > Yes, they do. If the bizobj in question is controlling the > transaction, it will handle the rollback on such errors, and then re- > raise the exception for the UI (or any other calling object) to > respond to. In Dabo, we define our own exceptions that are used when > certain problems are encountered; in the save() method alone, the > following exception classes are used: > > dException.BusinessRuleViolation > dException.MissingPKException > dException.ConnectionLostException > dException.NoRecordsException > dException.DBQueryException > dException.dException > > These different exception classes allow us to handle different > situations appropriately; all Dabo exception classes inherit from > dException.dException. In your code you could do something simple like: > > try: > self.save() > except dException.dException, e: > dabo.errorLog.write("Save failed with error: %s" % e) > self.rollbackTransaction() > > > -- Ed Leafe >
Ok. Thanks for the info. Miguel _______________________________________________ Post Messages to: [email protected] Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users Searchable Archives: http://leafe.com/archives/search/dabo-users This message: http://leafe.com/archives/byMID/[email protected]
