Mercurial > public > mercurial-scm > hg
comparison rust/hg-core/src/errors.rs @ 46483:2845892dd489
rust: Parse system and user configuration
CLI `--config` argument parsing is still missing, as is per-repo config
Differential Revision: https://phab.mercurial-scm.org/D9961
author | Simon Sapin <simon.sapin@octobus.net> |
---|---|
date | Thu, 04 Feb 2021 13:16:21 +0100 |
parents | d03b0601e0eb |
children | f031fe1c6ede |
comparison
equal
deleted
inserted
replaced
46482:39128182f04e | 46483:2845892dd489 |
---|---|
24 } | 24 } |
25 | 25 |
26 /// Details about where an I/O error happened | 26 /// Details about where an I/O error happened |
27 #[derive(Debug, derive_more::From)] | 27 #[derive(Debug, derive_more::From)] |
28 pub enum IoErrorContext { | 28 pub enum IoErrorContext { |
29 /// A filesystem operation returned `std::io::Error` | 29 /// A filesystem operation for the given file |
30 #[from] | 30 #[from] |
31 File(std::path::PathBuf), | 31 File(std::path::PathBuf), |
32 /// `std::env::current_dir` returned `std::io::Error` | 32 /// `std::env::current_dir` |
33 CurrentDir, | 33 CurrentDir, |
34 /// `std::env::current_exe` | |
35 CurrentExe, | |
34 } | 36 } |
35 | 37 |
36 impl HgError { | 38 impl HgError { |
37 pub fn corrupted(explanation: impl Into<String>) -> Self { | 39 pub fn corrupted(explanation: impl Into<String>) -> Self { |
38 // TODO: capture a backtrace here and keep it in the error value | 40 // TODO: capture a backtrace here and keep it in the error value |
67 impl fmt::Display for IoErrorContext { | 69 impl fmt::Display for IoErrorContext { |
68 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | 70 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { |
69 match self { | 71 match self { |
70 IoErrorContext::File(path) => path.display().fmt(f), | 72 IoErrorContext::File(path) => path.display().fmt(f), |
71 IoErrorContext::CurrentDir => f.write_str("current directory"), | 73 IoErrorContext::CurrentDir => f.write_str("current directory"), |
74 IoErrorContext::CurrentExe => f.write_str("current executable"), | |
72 } | 75 } |
73 } | 76 } |
74 } | 77 } |
75 | 78 |
76 pub trait IoResultExt<T> { | 79 pub trait IoResultExt<T> { |