Mercurial > public > mercurial-scm > hg-stable
comparison rust/hg-core/src/errors.rs @ 52074:de317a87ea6a
rust-pathauditor: match more of Python's behavior and display messages
We will make use of the path auditor when running our update fast-path,
and we want to output of it to be close enough.
author | Rapha?l Gom?s <rgomes@octobus.net> |
---|---|
date | Wed, 02 Oct 2024 20:29:48 +0200 |
parents | 491f3dd080eb |
children | 96b113d22b34 7be39c5110c9 |
comparison
equal
deleted
inserted
replaced
52073:a8cf6a852f11 | 52074:de317a87ea6a |
---|---|
1 use crate::config::ConfigValueParseError; | 1 use crate::config::ConfigValueParseError; |
2 use crate::exit_codes; | 2 use crate::exit_codes; |
3 use crate::utils::hg_path::HgPathError; | |
3 use std::fmt; | 4 use std::fmt; |
4 | 5 |
5 /// Common error cases that can happen in many different APIs | 6 /// Common error cases that can happen in many different APIs |
6 #[derive(Debug, derive_more::From)] | 7 #[derive(Debug, derive_more::From)] |
7 pub enum HgError { | 8 pub enum HgError { |
47 /// Censored revision data. | 48 /// Censored revision data. |
48 CensoredNodeError, | 49 CensoredNodeError, |
49 /// A race condition has been detected. This *must* be handled locally | 50 /// A race condition has been detected. This *must* be handled locally |
50 /// and not directly surface to the user. | 51 /// and not directly surface to the user. |
51 RaceDetected(String), | 52 RaceDetected(String), |
53 /// An invalid path was found | |
54 Path(HgPathError), | |
52 } | 55 } |
53 | 56 |
54 /// Details about where an I/O error happened | 57 /// Details about where an I/O error happened |
55 #[derive(Debug)] | 58 #[derive(Debug)] |
56 pub enum IoErrorContext { | 59 pub enum IoErrorContext { |
115 } | 118 } |
116 HgError::ConfigValueParseError(error) => error.fmt(f), | 119 HgError::ConfigValueParseError(error) => error.fmt(f), |
117 HgError::RaceDetected(context) => { | 120 HgError::RaceDetected(context) => { |
118 write!(f, "encountered a race condition {context}") | 121 write!(f, "encountered a race condition {context}") |
119 } | 122 } |
123 HgError::Path(hg_path_error) => write!(f, "{}", hg_path_error), | |
120 } | 124 } |
121 } | 125 } |
122 } | 126 } |
123 | 127 |
124 // TODO: use `DisplayBytes` instead to show non-Unicode filenames losslessly? | 128 // TODO: use `DisplayBytes` instead to show non-Unicode filenames losslessly? |