aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe-symfony-process/src/exception/process_timed_out_exception.rs
blob: b7e6595dce9900303d96fbd57c318c6eea71e457 (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
//! ref: composer/vendor/symfony/process/Exception/ProcessTimedOutException.php

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

#[derive(Debug)]
pub struct ProcessTimedOutException {
    inner: RuntimeException,
}

impl ProcessTimedOutException {
    pub fn new(process: &Process) -> Self {
        let exceeded_timeout = process.get_timeout();

        let message = format!(
            "The process \"{}\" exceeded the timeout of {} seconds.",
            process.get_command_line(),
            exceeded_timeout.map(|t| t.to_string()).unwrap_or_default(),
        );

        Self {
            inner: RuntimeException::new(message),
        }
    }
}

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