From 9a04df2ab4aed1800d06bf3a9642a2c6334f12c9 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Thu, 18 Jan 2024 09:52:17 -0500 Subject: [PATCH] feat: ability to get message without source from NpmVersionParseError --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- src/npm.rs | 6 ++++++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 941ede2..91c6320 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -80,9 +80,9 @@ checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6" [[package]] name = "monch" -version = "0.4.3" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4519a88847ba2d5ead3dc53f1060ec6a571de93f325d9c5c4968147382b1cbc3" +checksum = "b52c1b33ff98142aecea13138bd399b68aa7ab5d9546c300988c345004001eea" [[package]] name = "once_cell" diff --git a/Cargo.toml b/Cargo.toml index 9dab349..1c34c31 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" diff --git a/src/npm.rs b/src/npm.rs index 836a9ad..623d00d 100644 --- a/src/npm.rs +++ b/src/npm.rs @@ -42,6 +42,12 @@ pub struct NpmVersionParseError { pub(crate) source: ParseErrorFailureError, } +impl NpmVersionParseError { + pub fn message(&self) -> &str { + &self.source.message + } +} + pub fn parse_npm_version(text: &str) -> Result { let text = text.trim(); with_failure_handling(|input| {