Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions gnd/src/commands/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,8 @@ fn create_ipfs_manifest(
let manifest_str = fs::read_to_string(&manifest_path)
.with_context(|| format!("Failed to read manifest: {}", manifest_path.display()))?;

let mut value: serde_yaml::Value = serde_yaml::from_str(&manifest_str)?;
let mut value: serde_yaml::Value = serde_yaml::from_str(&manifest_str)
.with_context(|| format!("Failed to parse manifest: {}", manifest_path.display()))?;

// Update schema path to IPFS reference
if let Some(schema_path) = &manifest.schema {
Expand Down Expand Up @@ -747,7 +748,8 @@ fn write_output_manifest(
let manifest_str = fs::read_to_string(manifest_path)
.with_context(|| format!("Failed to read manifest: {:?}", manifest_path))?;

let mut value: serde_yaml::Value = serde_yaml::from_str(&manifest_str)?;
let mut value: serde_yaml::Value = serde_yaml::from_str(&manifest_str)
.with_context(|| format!("Failed to parse manifest: {:?}", manifest_path))?;

// Update schema path
if let Some(schema) = value.get_mut("schema")
Expand Down
2 changes: 1 addition & 1 deletion gnd/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ async fn main() -> Result<()> {
};

if let Err(e) = res {
eprintln!("Error: {}", e);
eprintln!("Error: {:#}", e);
std::process::exit(1);
}

Expand Down
41 changes: 41 additions & 0 deletions gnd/src/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,47 @@ dataSources:
);
}

#[test]
fn test_load_manifest_error_chain_includes_parse_context_and_cause() {
let temp_dir = TempDir::new().unwrap();
let manifest_path = temp_dir.path().join("subgraph.yaml");

let manifest_content = r#"
specVersion: 0.0.4
schema: {}
dataSources:
- kind: ethereum/contract
name: Token
network: mainnet
source:
abi: ERC20
mapping:
kind: ethereum/events
apiVersion: 0.0.6
language: wasm/assemblyscript
file: ./src/mapping.ts
entities:
- MyEntity
abis:
- name: ERC20
file: ./abis/ERC20.json
"#;

fs::write(&manifest_path, manifest_content).unwrap();

let err_chain = format!("{:#}", load_manifest(&manifest_path).unwrap_err());
assert!(
err_chain.contains("Failed to parse manifest"),
"Error chain should include manifest parse context, got: {}",
err_chain
);
assert!(
err_chain.contains("missing field") && err_chain.contains("file"),
"Error chain should include the underlying serde_yaml cause, got: {}",
err_chain
);
}

#[test]
fn test_load_manifest_missing_mapping_abis_fails() {
let temp_dir = TempDir::new().unwrap();
Expand Down
4 changes: 2 additions & 2 deletions gnd/src/watch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ where
{
// Do initial run
if let Err(e) = on_change().await {
eprintln!("Error during initial run: {}", e);
eprintln!("Error during initial run: {:#}", e);
}

println!("\n{}", initial_msg);
Expand Down Expand Up @@ -101,7 +101,7 @@ where
println!("\nFile change detected: {}\n", changed);

if let Err(e) = on_change().await {
eprintln!("Error during rebuild: {}", e);
eprintln!("Error during rebuild: {:#}", e);
}
}
}
Expand Down