-
Notifications
You must be signed in to change notification settings - Fork 299
Open
Description
Here is one strategy that I think we should do to improve the ergonomics of errors. Broadly speaking, there are two ways users can interact with secp API.
- Users who just bubble up the error.
- Users who match on errors on variants and deal with them in some way.
Right now, our API is not the most convenient for users (2). For example, Signature::from_der
returns only one error variant but the user is forced to match against all variants.
Proposal
Have each API return a separate error type that does not have any variants that are unreachable. Provide a top level common error type to unify all error types for users who just want to bubble up errors.
pub Error{
InvalidSig(InvalidSigError),
PubkeyParseError(PubKeyParseError),
}
impl Signature{
pub fn from_der() -> Result<.., InvalidSigError>;
}
impl FromStr for PublicKey {
pub fn from_str() -> Result<..., PubkeyParseError>;
}
impl From<InvalidSigError> for Error {}
impl From<PubkeyParseError> for Error {}
Kixunil
Metadata
Metadata
Assignees
Labels
No labels