summaryrefslogtreecommitdiff
path: root/src/cmds/converter/space_error.rs
blob: 4ff7e7e2a473a75eb4d07327ee2f9928c292b61d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
use crate::systems::cmd::errors::CmdExecuteError;
use just_enough_vcs::system::space::error::SpaceError;
use rust_i18n::t;

pub struct JVSpaceErrorConverter;

impl JVSpaceErrorConverter {
    pub fn to_exec_error(err: SpaceError) -> CmdExecuteError {
        match err {
            SpaceError::SpaceNotFound => {
                CmdExecuteError::Error(t!("space_error.space_not_found").trim().to_string())
            }
            SpaceError::PathFormatError(path_format_error) => CmdExecuteError::Error(
                t!("space_error.path_fmt_error", error = path_format_error)
                    .trim()
                    .to_string(),
            ),
            SpaceError::Io(error) => CmdExecuteError::Io(error),
            SpaceError::Other(msg) => CmdExecuteError::Error(msg),
        }
    }
}