@@ -519,24 +519,31 @@ pub enum Error {
519
519
InvalidTweak ,
520
520
}
521
521
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 {
526
525
Error :: IncorrectSignature => "secp: signature failed verification" ,
527
526
Error :: InvalidMessage => "secp: message was not 32 bytes (do you need to hash?)" ,
528
527
Error :: InvalidPublicKey => "secp: malformed public key" ,
529
528
Error :: InvalidSignature => "secp: malformed signature" ,
530
529
Error :: InvalidSecretKey => "secp: malformed or out-of-range secret key" ,
531
530
Error :: InvalidRecoveryId => "secp: bad recovery id" ,
532
531
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 ( ) )
535
540
}
536
541
}
537
542
538
543
#[ 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
+ }
540
547
541
548
/// Marker trait for indicating that an instance of `Secp256k1` can be used for signing.
542
549
pub trait Signing { }
0 commit comments