Skip to content

Commit 75e0a65

Browse files
committed
fix
1 parent 0dece66 commit 75e0a65

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

rust/signed_doc/examples/mk_signed_doc.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use std::{
88
path::PathBuf,
99
};
1010

11+
use anyhow::Context;
1112
use catalyst_signed_doc::{Builder, CatalystSignedDocument, IdUri, Metadata};
1213
use clap::Parser;
1314
use ed25519_dalek::pkcs8::DecodePrivateKey;
@@ -116,14 +117,13 @@ fn inspect_signed_doc(cose_bytes: &[u8]) -> anyhow::Result<()> {
116117

117118
fn 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

125125
fn 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

129129
fn load_json_from_file<T>(path: &PathBuf) -> anyhow::Result<T>
@@ -136,7 +136,7 @@ where T: for<'de> serde::Deserialize<'de> {
136136
fn 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

142142
fn load_secret_key_from_file(sk_path: &PathBuf) -> anyhow::Result<ed25519_dalek::SigningKey> {

rust/signed_doc/src/builder.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@ impl Builder {
2626
}
2727

2828
/// Set document metadata
29-
///
30-
/// # Errors
31-
/// - Fails if it is invalid metadata JSON object.
3229
#[must_use]
3330
pub fn with_metadata(mut self, metadata: Metadata) -> Self {
3431
self.metadata = Some(metadata);

0 commit comments

Comments
 (0)