Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
members = [
"rust/codelist-rs",
"rust/codelist-validator-rs",
"rust/codelist-builder-rs",
"bindings/python",
"bindings/r/src/rust"
]
2 changes: 1 addition & 1 deletion bindings/python/src/codelist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ impl PyCodeList {
match custom_regex {
Some(regex_str) => {
let regex = Regex::new(&regex_str)
.map_err(|e| PyValueError::new_err(format!("Invalid regex: {}", e)))?;
.map_err(|e| PyValueError::new_err(format!("Invalid regex: {e}")))?;
self.inner
.validate_codes(Some(&regex))
.map_err(|e| PyValueError::new_err(e.to_string()))?
Expand Down
8 changes: 7 additions & 1 deletion rust/codelist-builder-rs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@ description = "Builder library for medical codelists"
[dependencies]
codelist-rs = { path = "../codelist-rs" }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
thiserror = { version = "2.0.9" }
thiserror-ext = { version = "0.2.1" }
reqwest = { version = "0.12.2" }
csv = { version = "1.3.1" }
async-trait = "0.1"


[dev-dependencies]
tokio = { version = "1.0", features = ["full"] }
wiremock = { version = "0.6.4" }
24 changes: 24 additions & 0 deletions rust/codelist-builder-rs/src/errors.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//! This file contains custom errors for the codelist-builder library

/// Enum to represent the different types of errors that can occur in the
/// codelist-builder library

#[derive(Debug, thiserror::Error, thiserror_ext::Construct)]
pub enum CodeListBuilderError {
#[error("Invalid usage year: {name}")]
InvalidUsageYear { name: String },

#[error("Invalid usage data: {name}")]
InvalidUsageData { name: String },

#[error("HTTP error code: {code}: {body}")]
HttpErrorCode { code: String, body: String },

#[error("HTTP request error: {0}")]
#[construct(skip)]
ReqwestError(#[from] reqwest::Error),

#[error("CSV error: {0}")]
#[construct(skip)]
CSVError(#[from] csv::Error),
}
3 changes: 3 additions & 0 deletions rust/codelist-builder-rs/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pub mod errors;
pub mod snomed_usage_data;
pub mod usage_year;
Loading
Loading