From 9f82b4e146e6090897c876a02f5eee697b85e979 Mon Sep 17 00:00:00 2001 From: Federico Terzi Date: Sun, 12 Jun 2022 12:19:24 +0200 Subject: [PATCH] feat(package): add path information when manifest parsing fails. #1119 --- espanso-package/src/manifest.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/espanso-package/src/manifest.rs b/espanso-package/src/manifest.rs index 172a3a1..b6ff60f 100644 --- a/espanso-package/src/manifest.rs +++ b/espanso-package/src/manifest.rs @@ -19,7 +19,7 @@ use std::path::Path; -use anyhow::Result; +use anyhow::{Context, Result}; use serde::{Deserialize, Serialize}; #[derive(Debug, PartialEq, Serialize, Deserialize)] @@ -34,7 +34,13 @@ pub struct Manifest { impl Manifest { pub fn parse(manifest_path: &Path) -> Result { let manifest_str = std::fs::read_to_string(manifest_path)?; - Ok(serde_yaml::from_str(&manifest_str)?) + + serde_yaml::from_str(&manifest_str).with_context(|| { + format!( + "Failed manifest parsing for path: {}", + manifest_path.display() + ) + }) } }