surround open command by a try/except handler