1 use crate::ui::utf8_to_local; |
1 use crate::ui::utf8_to_local; |
2 use crate::ui::UiError; |
2 use crate::ui::UiError; |
3 use crate::NoRepoInCwdError; |
3 use crate::NoRepoInCwdError; |
4 use format_bytes::format_bytes; |
4 use format_bytes::format_bytes; |
5 use hg::config::{ConfigError, ConfigParseError}; |
5 use hg::config::{ConfigError, ConfigParseError, ConfigValueParseError}; |
6 use hg::errors::HgError; |
6 use hg::errors::HgError; |
7 use hg::repo::RepoError; |
7 use hg::repo::RepoError; |
8 use hg::revlog::revlog::RevlogError; |
8 use hg::revlog::revlog::RevlogError; |
9 use hg::utils::files::get_bytes_from_path; |
9 use hg::utils::files::get_bytes_from_path; |
|
10 use hg::{DirstateError, DirstateMapError, StatusError}; |
10 use std::convert::From; |
11 use std::convert::From; |
11 |
12 |
12 /// The kind of command error |
13 /// The kind of command error |
13 #[derive(Debug)] |
14 #[derive(Debug)] |
14 pub enum CommandError { |
15 pub enum CommandError { |
56 HgError::UnsupportedFeature(message) => { |
57 HgError::UnsupportedFeature(message) => { |
57 CommandError::unsupported(message) |
58 CommandError::unsupported(message) |
58 } |
59 } |
59 _ => CommandError::abort(error.to_string()), |
60 _ => CommandError::abort(error.to_string()), |
60 } |
61 } |
|
62 } |
|
63 } |
|
64 |
|
65 impl From<ConfigValueParseError> for CommandError { |
|
66 fn from(error: ConfigValueParseError) -> Self { |
|
67 CommandError::abort(error.to_string()) |
61 } |
68 } |
62 } |
69 } |
63 |
70 |
64 impl From<UiError> for CommandError { |
71 impl From<UiError> for CommandError { |
65 fn from(_error: UiError) -> Self { |
72 fn from(_error: UiError) -> Self { |
142 )), |
149 )), |
143 RevlogError::Other(error) => error.into(), |
150 RevlogError::Other(error) => error.into(), |
144 } |
151 } |
145 } |
152 } |
146 } |
153 } |
|
154 |
|
155 impl From<StatusError> for CommandError { |
|
156 fn from(error: StatusError) -> Self { |
|
157 CommandError::abort(format!("{}", error)) |
|
158 } |
|
159 } |
|
160 |
|
161 impl From<DirstateMapError> for CommandError { |
|
162 fn from(error: DirstateMapError) -> Self { |
|
163 CommandError::abort(format!("{}", error)) |
|
164 } |
|
165 } |
|
166 |
|
167 impl From<DirstateError> for CommandError { |
|
168 fn from(error: DirstateError) -> Self { |
|
169 match error { |
|
170 DirstateError::Common(error) => error.into(), |
|
171 DirstateError::Map(error) => error.into(), |
|
172 } |
|
173 } |
|
174 } |