Skip to content

Commit

Permalink
feat: ability to get message without source from NpmVersionParseError (
Browse files Browse the repository at this point in the history
  • Loading branch information
dsherret authored Jan 20, 2024
1 parent dda7291 commit 52d59ba
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ authors = ["the Deno authors"]
license = "MIT"

[dependencies]
monch = "0.4.3"
monch = "0.5.0"
once_cell = "1.17.0"
serde = { version = "1.0.130", features = ["derive", "rc"] }
thiserror = "1.0.24"
Expand Down
7 changes: 7 additions & 0 deletions src/npm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ pub struct NpmVersionParseError {
pub(crate) source: ParseErrorFailureError,
}

impl NpmVersionParseError {
/// Message of the error excluding the code snippet.
pub fn message(&self) -> &str {
&self.source.message
}
}

pub fn parse_npm_version(text: &str) -> Result<Version, NpmVersionParseError> {
let text = text.trim();
with_failure_handling(|input| {
Expand Down

0 comments on commit 52d59ba

Please sign in to comment.