exception handling for is_dir/is_file