Skip to content

Commit

Permalink
Better error during parsing. Issue quilt#82
Browse files Browse the repository at this point in the history
  • Loading branch information
gzanitti committed Oct 10, 2023
1 parent 7bbfe8e commit 6a25d9d
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions etk-asm/src/ingest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,15 @@ mod error {
},

/// An error that occurred while parsing a file.
#[snafu(context(false))]
#[non_exhaustive]
#[snafu(display("parsing failed"))]
#[snafu(display("parsing failed on path `{}`", path.to_string_lossy()))]
Parse {
/// The underlying source of this error.
#[snafu(backtrace)]
source: ParseError,

/// The location of the error.
path: PathBuf,
},

/// An error that occurred while assembling a file.
Expand Down Expand Up @@ -305,7 +307,9 @@ where
}

fn preprocess(&mut self, program: &mut Program, src: &str) -> Result<Vec<RawOp>, Error> {
let nodes = parse_asm(src)?;
let nodes = parse_asm(src).context(error::Parse {
path: program.sources.last().unwrap().clone(),
})?;
let mut raws = Vec::new();
for node in nodes {
match node {
Expand Down

0 comments on commit 6a25d9d

Please sign in to comment.