nvd_cves/
error.rs

1//! cve error
2use thiserror::Error as ThisError;
3
4pub type Result<T> = std::result::Result<T, CVEError>;
5
6#[derive(ThisError, Debug, Clone)]
7pub enum CVEError {
8  #[error("error decoding value `{value}`, not well formed UTF-8")]
9  Utf8Error {
10    #[source]
11    source: std::str::Utf8Error,
12    value: String,
13  },
14  #[error("invalid prefix for `{value}`")]
15  InvalidPrefix { value: String },
16  #[error("Invalid CVE type `{value}`")]
17  InvalidCveType { value: String },
18  #[error("Invalid CVSS `{value}` at {scope}")]
19  InvalidCVSS { value: String, scope: String },
20  #[error("invalid cvss version `{value}` ({expected})")]
21  InvalidCVSSVersion { value: String, expected: String },
22}
23
24impl From<&CVEError> for CVEError {
25  fn from(value: &CVEError) -> Self {
26    value.clone()
27  }
28}