@@ -523,24 +523,31 @@ pub enum Error {
523
523
InvalidTweak ,
524
524
}
525
525
526
- // Passthrough Debug to Display, since errors should be user-visible
527
- impl fmt:: Display for Error {
528
- fn fmt ( & self , f : & mut fmt:: Formatter ) -> Result < ( ) , fmt:: Error > {
529
- let res = match * self {
526
+ impl Error {
527
+ fn as_str ( & self ) -> & str {
528
+ match * self {
530
529
Error :: IncorrectSignature => "secp: signature failed verification" ,
531
530
Error :: InvalidMessage => "secp: message was not 32 bytes (do you need to hash?)" ,
532
531
Error :: InvalidPublicKey => "secp: malformed public key" ,
533
532
Error :: InvalidSignature => "secp: malformed signature" ,
534
533
Error :: InvalidSecretKey => "secp: malformed or out-of-range secret key" ,
535
534
Error :: InvalidRecoveryId => "secp: bad recovery id" ,
536
535
Error :: InvalidTweak => "secp: bad tweak" ,
537
- } ;
538
- f. write_str ( res)
536
+ }
537
+ }
538
+ }
539
+
540
+ // Passthrough Debug to Display, since errors should be user-visible
541
+ impl fmt:: Display for Error {
542
+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> Result < ( ) , fmt:: Error > {
543
+ f. write_str ( self . as_str ( ) )
539
544
}
540
545
}
541
546
542
547
#[ cfg( feature = "std" ) ]
543
- impl std:: error:: Error for Error { }
548
+ impl std:: error:: Error for Error {
549
+ fn description ( & self ) -> & str { self . as_str ( ) }
550
+ }
544
551
545
552
/// Marker trait for indicating that an instance of `Secp256k1` can be used for signing.
546
553
pub trait Signing { }
0 commit comments