Skip to content

Potentially confusing examples in documentation #42

@codesections

Description

@codesections

Thanks very much for this crate.

The examples in the README and the documentation all show using dotenv::dotenv().ok() or dotenv::from_filename("custom.env").ok(). The .ok() causes dotenv to silently ignore errors in loading the environment file. Perhaps that should have been obvious to me, but it wasn't, especially when I first started using the crate a few months ago. Given how explicit Rust typically is with errors, this wasn't the behavior I expected. I've learned my lesson, but wondered if others might also have been confused.

I understand not wanting to have full error handling in examples, but the most common way I've seen this handled in the Rust ecosystem is to use expect. Would you be open to changing the documentation examples to something like dotenv::dotenv().expect("Could not open .env file")? If so, I'd be happy to submit a PR.

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