@@ -519,24 +519,31 @@ pub enum Error {
519519 InvalidTweak ,
520520}
521521
522- // Passthrough Debug to Display, since errors should be user-visible
523- impl fmt:: Display for Error {
524- fn fmt ( & self , f : & mut fmt:: Formatter ) -> Result < ( ) , fmt:: Error > {
525- let res = match * self {
522+ impl Error {
523+ fn as_str ( & self ) -> & str {
524+ match * self {
526525 Error :: IncorrectSignature => "secp: signature failed verification" ,
527526 Error :: InvalidMessage => "secp: message was not 32 bytes (do you need to hash?)" ,
528527 Error :: InvalidPublicKey => "secp: malformed public key" ,
529528 Error :: InvalidSignature => "secp: malformed signature" ,
530529 Error :: InvalidSecretKey => "secp: malformed or out-of-range secret key" ,
531530 Error :: InvalidRecoveryId => "secp: bad recovery id" ,
532531 Error :: InvalidTweak => "secp: bad tweak" ,
533- } ;
534- f. write_str ( res)
532+ }
533+ }
534+ }
535+
536+ // Passthrough Debug to Display, since errors should be user-visible
537+ impl fmt:: Display for Error {
538+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> Result < ( ) , fmt:: Error > {
539+ f. write_str ( self . as_str ( ) )
535540 }
536541}
537542
538543#[ cfg( feature = "std" ) ]
539- impl std:: error:: Error for Error { }
544+ impl std:: error:: Error for Error {
545+ fn description ( & self ) -> & str { self . as_str ( ) }
546+ }
540547
541548/// Marker trait for indicating that an instance of `Secp256k1` can be used for signing.
542549pub trait Signing { }
0 commit comments