aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe-symfony-process/src/exception/process_signaled_exception.rs
blob: 8c69d353c2f317aedf1fbcfec773236a47e8cce2 (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/vendor/symfony/process/Exception/ProcessSignaledException.php

use crate::exception::RuntimeException;
use crate::process::Process;

#[derive(Debug)]
pub struct ProcessSignaledException {
    inner: RuntimeException,
    signal: i64,
}

impl ProcessSignaledException {
    pub fn new(process: &mut Process) -> anyhow::Result<Self> {
        let signal = process.get_term_signal()?;

        Ok(Self {
            inner: RuntimeException::new(format!(
                "The process has been signaled with signal \"{}\".",
                signal
            )),
            signal,
        })
    }

    pub fn get_signal(&self) -> i64 {
        self.signal
    }
}

shirabe_php_shim::impl_php_exception!(
    ProcessSignaledException,
    inner,
    r"Symfony\Component\Process\Exception\ProcessSignaledException"
);