blob: a63edda3d4d4534fa746ed032636f349de07a778 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
//! ref: composer/src/Composer/Json/JsonValidationException.php
use shirabe_php_shim::Exception;
#[derive(Debug)]
pub struct JsonValidationException {
inner: Exception,
pub(crate) errors: Vec<String>,
}
impl JsonValidationException {
pub fn new(message: String, errors: Vec<String>) -> Self {
Self {
inner: Exception { message, code: 0 },
errors,
}
}
pub fn get_errors(&self) -> &Vec<String> {
&self.errors
}
pub fn get_message(&self) -> &str {
&self.inner.message
}
}
impl std::fmt::Display for JsonValidationException {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.inner.message)
}
}
impl std::error::Error for JsonValidationException {}
|