Skip to content

builder build() methods panic instead of returning Result #350

@cachebag

Description

@cachebag

VpnCredentialsBuilder::build() and EapOptions::builder().build() use expect() / panic!() for missing required fields instead of returning Result.

this contradicts the project convention of no unwrap() in library code, and more importantly it means downstream callers can't handle missing fields gracefully — their process just crashes.

VpnCredentialsBuilder::build()wireguard.rs:511-524:

pub fn build(self) -> VpnCredentials {
    let name = self.name.expect("name is required");
    let gateway = self.gateway.expect("gateway is required");
    let private_key = self.private_key.expect("private_key is required");
    if self.peers.is_empty() {
        panic!("at least one peer is required");
    }
    // ...
}

EapOptions builderwifi.rs:504-517: same pattern with expect() on identity and password.

both should return Result<T, ConnectionError> (or a dedicated builder error) so callers can use ? instead of catching panics.

Metadata

Metadata

Assignees

No one assigned

    Labels

    api-surfacePublic API design, re-exports, and semver-relevant changesbugSomething isn't workingbuildersConnection builder API and validationnmrsChanges to nmrs

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions