Catch all exceptions in the PutMessage() function.