justinwongcn/moonpgp/error does not have a README file

    PgpError

    pub(all) suberror PgpError {
    PgpError(msg~ : String)
    Malformed(msg~ : String)
    Unsupported(msg~ : String)
    WrongPassphrase(msg~ : String)
    }

    The single error type raised by every package in this module.

    The four variants mark the failure classes a caller can branch on; every variant carries the same human-readable message the library has always raised, so existing message matching keeps working:

    • PgpError — everything else: caller argument mistakes, internal invariant violations, and failures that belong to no other class.
    • Malformed — the input data does not parse or violates the format (bad lengths, corrupt tags, unknown structure). The message tells corrupt input from caller error.
    • Unsupported — the input is well-formed but carries an algorithm, version, or feature this library does not implement.
    • WrongPassphrase — a passphrase check failed definitively. Raised when unlocking a key or decrypting a passphrase-protected message with the wrong passphrase. On AEAD-protected key material the same variant also fires for a corrupted key; the message text tells the two cases apart.

    Example

    Branch on the variant; the message stays available either way.

    test "match picks the variant, message stays available" {
    let e : @error.PgpError = WrongPassphrase(
    msg="api: wrong passphrase (checksum failed)",
    )
    match e {
    WrongPassphrase(msg~) =>
    inspect(msg, content="api: wrong passphrase (checksum failed)")
    _ => @error.fail("expected WrongPassphrase")
    }
    }
    impl Show for PgpError

    PgpError::output

    fn PgpError::output(self : PgpError, logger : &Logger) -> Unit

    PgpError::to_string

    fn PgpError::to_string(self : PgpError) -> String

    fail

    fn[T] fail(msg : String) -> T raise PgpError

    Raise a generic PgpError with the given message.

    malformed

    fn[T] malformed(msg : String) -> T raise PgpError

    Raise Malformed: the input data does not parse or violates the format.

    require

    fn[T] require(opt : T?, msg : String) -> T raise PgpError

    Unwrap an Option that must be present, raising msg when it is None.

    unsupported

    fn[T] unsupported(msg : String) -> T raise PgpError

    Raise Unsupported: the input is well-formed but carries an algorithm, version, or feature this library does not implement.

    wrong_passphrase

    fn[T] wrong_passphrase(msg : String) -> T raise PgpError

    Raise WrongPassphrase: a passphrase check failed definitively.

    Source Files