@@ -8,6 +8,7 @@ use std::{
88 path:: PathBuf ,
99} ;
1010
11+ use anyhow:: Context ;
1112use catalyst_signed_doc:: { Builder , CatalystSignedDocument , IdUri , Metadata } ;
1213use clap:: Parser ;
1314use ed25519_dalek:: pkcs8:: DecodePrivateKey ;
@@ -116,14 +117,13 @@ fn inspect_signed_doc(cose_bytes: &[u8]) -> anyhow::Result<()> {
116117
117118fn save_signed_doc ( signed_doc : CatalystSignedDocument , path : & PathBuf ) -> anyhow:: Result < ( ) > {
118119 let mut bytes: Vec < u8 > = Vec :: new ( ) ;
119- minicbor:: encode ( signed_doc, & mut bytes)
120- . map_err ( |e| anyhow:: anyhow!( "Failed to encode document: {e}" ) ) ?;
120+ minicbor:: encode ( signed_doc, & mut bytes) . context ( "Failed to encode document" ) ?;
121121
122122 write_bytes_to_file ( & bytes, path)
123123}
124124
125125fn signed_doc_from_bytes ( cose_bytes : & [ u8 ] ) -> anyhow:: Result < CatalystSignedDocument > {
126- minicbor:: decode ( cose_bytes) . map_err ( |e| anyhow :: anyhow! ( "Invalid Catalyst Document: {e}" ) )
126+ minicbor:: decode ( cose_bytes) . context ( "Invalid Catalyst Document" )
127127}
128128
129129fn load_json_from_file < T > ( path : & PathBuf ) -> anyhow:: Result < T >
@@ -136,7 +136,7 @@ where T: for<'de> serde::Deserialize<'de> {
136136fn write_bytes_to_file ( bytes : & [ u8 ] , output : & PathBuf ) -> anyhow:: Result < ( ) > {
137137 File :: create ( output) ?
138138 . write_all ( bytes)
139- . map_err ( |e| anyhow :: anyhow !( "Failed to write to file {output:?}: {e }" ) )
139+ . context ( format ! ( "Failed to write to file {output:?}" ) )
140140}
141141
142142fn load_secret_key_from_file ( sk_path : & PathBuf ) -> anyhow:: Result < ed25519_dalek:: SigningKey > {
0 commit comments