[CA-119964] Trap exceptions and recover gracefully

Signed-off-by: Ben Chalmers <Ben.Chalmers@citrix.com>
Merge pull request #7 from benchalmers/ca-119964

[CA-119964] Trap exceptions and recover gracefully

Approved-by: Ben Chalmers <ben.chalmers@citrix.com>