Skip to content

Improve how failures are handled by the directory_files_read function #6

@fhightower

Description

@fhightower

What?

Currently, if the directory_files_read function is unable to read one file in a directory, it raises an exception and does so in a way that is difficult to handle.

For example, let's say there are four files in a directory and the directory_files_read reads the first two correctly but fails with a UnicodeDecodeError on the third:

for path, contents in directory_files_read(directory_path, recursive=False):
    ...

There is no good way I'm aware of to handle this failure in a way that would let you skip the error and move on.

How?

I believe the best solution is to add error handling into this function.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesttime est: 1 hourWe estimate this issue will take 1 hour to complete

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions