comparison rust/hg-core/src/errors.rs @ 46799:bcdcb4423ae3

rhg: Add more conversions between error types This allows using the `?` operator in more places, as the next commit does. Differential Revision: https://phab.mercurial-scm.org/D10238
author Simon Sapin <simon.sapin@octobus.net>
date Fri, 19 Mar 2021 13:18:53 +0100
parents 97ac588b6d9e
children 6e49769b7f97
comparison
equal deleted inserted replaced
46798:38f55ef058fb 46799:bcdcb4423ae3
86 write!(f, "abort: {}", explanation) 86 write!(f, "abort: {}", explanation)
87 } 87 }
88 HgError::UnsupportedFeature(explanation) => { 88 HgError::UnsupportedFeature(explanation) => {
89 write!(f, "unsupported feature: {}", explanation) 89 write!(f, "unsupported feature: {}", explanation)
90 } 90 }
91 HgError::ConfigValueParseError(ConfigValueParseError { 91 HgError::ConfigValueParseError(error) => error.fmt(f),
92 origin: _,
93 line: _,
94 section,
95 item,
96 value,
97 expected_type,
98 }) => {
99 // TODO: add origin and line number information, here and in
100 // corresponding python code
101 write!(
102 f,
103 "config error: {}.{} is not a {} ('{}')",
104 String::from_utf8_lossy(section),
105 String::from_utf8_lossy(item),
106 expected_type,
107 String::from_utf8_lossy(value)
108 )
109 }
110 } 92 }
111 } 93 }
112 } 94 }
113 95
114 // TODO: use `DisplayBytes` instead to show non-Unicode filenames losslessly? 96 // TODO: use `DisplayBytes` instead to show non-Unicode filenames losslessly?