aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe-external-packages/src/seld/json_lint/parsing_exception.rs
blob: b756c1b10696e6c9794d5af60a1e11d77a441496 (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
#[derive(Debug)]
pub struct ParsingException {
    pub message: String,
    pub code: i64,
}

impl ParsingException {
    pub fn new(message: String, _details: Option<shirabe_php_shim::PhpMixed>) -> Self {
        Self { message, code: 0 }
    }

    pub fn get_message(&self) -> &str {
        &self.message
    }

    pub fn get_details(&self) -> indexmap::IndexMap<String, shirabe_php_shim::PhpMixed> {
        // TODO(phase-b): PHP ParsingException exposes ['text', 'line', 'token'] details
        indexmap::IndexMap::new()
    }
}

impl std::fmt::Display for ParsingException {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        write!(f, "{}", self.message)
    }
}

impl std::error::Error for ParsingException {}