Wrapped data writing in try/catch block.