Issue 626 by Pjohans: try catch on drupal_write_record to catch unhandle...

...d PDO exception.

Issue 626 describes an unhandled PDO exception which causes the page to crash. I couldn't recreate the issue locally, but am 99% sure that it origins from drupal_write_record in ting.controllers.inc. Either way the code potentially throws an unhandled exception, so the try catch can do no harm.
If the exception is thrown in this call then the above call should be reverted.
This should be handled with a transaction.
I have several times seen a situation where the database contains a ting_object with vid set to NULL, which causes in all future calls to this code to fail until the record with vid = NULL have been deleted.
This situation is probably caused by an exception while running the second drupal_write_record.