Skip to content

create src/errors.rs with generic errors for the entire crate #215

@dlaehnemann

Description

@dlaehnemann

In PR #165 (now superseded by PR #214 ), the review led to the idea of defining generic errors like FileNotFound and NonUnicodePath on the highest level of the crate, i.e. in a new file src/errors.rs. This avoids redundantly defining such errors for all submodules. Currently, the two example errors are defined both for bam, tbx and faidx:

#[snafu(display("file not found: {}", path.display()))]
FileNotFound { path: PathBuf },
#[snafu(display("invalid (non-unique) characters in path"))]
NonUnicodePath,

#[snafu(display("file not found: {}", path.display()))]
FileNotFound { path: PathBuf },
#[snafu(display("invalid (non-unique) characters in path"))]
NonUnicodePath,

#[snafu(display("file not found: {}", path.display()))]
FileNotFound { path: PathBuf },
#[snafu(display("invalid (non-unicode) characters in path"))]
NonUnicodePath,

And NonUnicodePath is also defined for bcf, but FileNotFound is missing there. So such high-level definition could also help clean up the errors a bit:

#[snafu(display("invalid (non-unique) characters in path"))]
NonUnicodePath,

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions