Add exception handling for lfs.dir()