summaryrefslogtreecommitdiff
path: root/src/cmds/converter/make_sheet_error.rs
blob: 8bbc45dab9545adc638e49faa4138d01b0cc67ae (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::workspace::workspace::manager::sheet_state::error::MakeSheetError;
use rust_i18n::t;

pub struct MakeSheetErrorConverter;

impl MakeSheetErrorConverter {
    pub fn to_exec_error(err: MakeSheetError) -> CmdExecuteError {
        match err {
            MakeSheetError::SheetAlreadyExists => {
                CmdExecuteError::Error(t!("make_sheet_error.sheet_already_exists").to_string())
            }
            MakeSheetError::SheetNotFound => {
                CmdExecuteError::Error(t!("make_sheet_error.sheet_not_found").to_string())
            }
            MakeSheetError::Io(error) => CmdExecuteError::Io(error),
            MakeSheetError::Other(error) => CmdExecuteError::Error(
                t!("make_sheet_error.other", error = error.to_string()).to_string(),
            ),
        }
    }
}