Skip to content

Commit

Permalink
Improve Anchor and Hardhat error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
smoelius committed Jul 3, 2024
1 parent de21f2e commit e6e756e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions backends/src/anchor/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use super::{ts, OutputAccessors, OutputStrippedOfAnsiScapes, ParseAdapter, ParseHigh, RunHigh};
use anyhow::{anyhow, Result};
use anyhow::{anyhow, Context, Result};
use log::debug;
use necessist_core::{
framework::{Interface, Postprocess, SourceFileTestSpanMap},
Expand Down Expand Up @@ -34,7 +34,8 @@ impl Anchor {

pub fn new(context: &LightContext) -> Result<Self> {
let anchor_toml = context.root.join("Anchor.toml");
let contents = read_to_string(&anchor_toml)?;
let contents = read_to_string(&anchor_toml)
.with_context(|| format!(r#"Failed to read "{}""#, anchor_toml.display()))?;
let mut document = contents.parse::<DocumentMut>()?;
let (prefix, suffix) = edit_test_script(&mut document, parse_test_value)?;
Ok(Self {
Expand Down
5 changes: 3 additions & 2 deletions backends/src/parsing.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use super::{GenericVisitor, ParseHigh};
use anyhow::Result;
use anyhow::{Context, Result};
use heck::ToKebabCase;
use necessist_core::{
config,
Expand Down Expand Up @@ -381,7 +381,8 @@ impl<T: ParseLow> ParseHigh for ParseAdapter<T> {

if source_files.is_empty() {
for entry in walk_dir_results {
let entry = entry?;
let entry = entry
.with_context(|| format!(r#"Failed to walk "{}""#, context.root.display()))?;
let path = entry.path();

if !path.is_file() {
Expand Down

0 comments on commit e6e756e

Please sign in to comment.