Skip to content

Commit

Permalink
Improve error message
Browse files Browse the repository at this point in the history
  • Loading branch information
Mnwa committed Aug 17, 2024
1 parent b1d8ce8 commit f353601
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
2 changes: 1 addition & 1 deletion css-minify/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "css-minify"
version = "0.5.1"
version = "0.5.2"
authors = ["Mnwa <[email protected]>"]
edition = "2021"
description = "CSS parser and minificator based on nom"
Expand Down
11 changes: 4 additions & 7 deletions css-minify/src/optimizations/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,13 +190,10 @@ impl Display for MError<'_> {
Err::Failure(e) => Some(e.input.len()),
};
if let Some(size) = unparsed_size {
let parsed_css = &self.0[..self.0.len() - size];
let parsed_css = &self.0[..size];
let (count, last_line) = parsed_css.lines().enumerate().last().unwrap();

write!(
f,
"Invalid block at line {}",
parsed_css.lines().count() + 1
)
write!(f, "Invalid block at line {}:{}", count + 1, last_line.len())
} else {
write!(f, "Invalid css")
}
Expand Down Expand Up @@ -271,7 +268,7 @@ mod test {
)
.unwrap_err()
.to_string(),
"Invalid block at line 6"
"Invalid block at line 9:28"
)
}

Expand Down

0 comments on commit f353601

Please sign in to comment.