rair_env/err.rs
1/*
2 * err.rs: error handling for renv.
3 * Copyright (C) 2019 Oddcoder
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17use std::fmt;
18
19#[derive(Debug, PartialEq)]
20pub enum EnvErr {
21 NotFound,
22 DifferentType,
23 CbFailed,
24 AlreadyExist,
25}
26
27impl fmt::Display for EnvErr {
28 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
29 match self {
30 EnvErr::NotFound => write!(f, "Environment variable not found."),
31 EnvErr::DifferentType => write!(f, "Environment variable has different type."),
32 EnvErr::CbFailed => write!(f, "Call back failed."),
33 EnvErr::AlreadyExist => write!(f, "Environment variable already exist."),
34 }
35 }
36}