flaggy_values/error.rs
1// Copyright 2015 Axel Rasmussen
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15use thiserror::Error;
16
17#[derive(Debug, Error)]
18pub enum ValueError {
19 /// A malformed boolean value was found.
20 #[error("Invalid boolean value '{0}'")]
21 BadBoolean(String),
22 /// A `Command` callback parameter was of the wrong type, so flag value
23 /// passing failed.
24 #[error("Incorrect command callback parameter: {0}")]
25 CallbackParameter(String),
26 /// No command was specified.
27 #[error("No command specified")]
28 MissingCommand,
29 /// A required flag was not provided.
30 #[error("No value provided for required flag '{0}'")]
31 MissingFlag(String),
32 /// A flag was provided with no associated value.
33 #[error("Flag '{0}' provided without any value")]
34 MissingValue(String),
35 /// An unrecognized command was provided.
36 #[error("Unknown command '{0}'")]
37 UnknownCommand(String),
38 /// An unrecognized flag was provided.
39 #[error("Unknown flag '{0}'")]
40 UnknownFlag(String),
41}
42
43pub type ValueResult<T> = Result<T, ValueError>;