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