Mercurial > public > mercurial-scm > hg
comparison rust/hg-core/src/errors.rs @ 49488:9f14126cfc4c
rust: add support for hints in error messages
This will be used by the narrow support code in the next commit.
author | Rapha?l Gom?s <rgomes@octobus.net> |
---|---|
date | Tue, 19 Jul 2022 17:07:09 +0200 |
parents | 3f86ee422095 |
children | 491f3dd080eb |
comparison
equal
deleted
inserted
replaced
49487:e8481625c582 | 49488:9f14126cfc4c |
---|---|
31 /// The message is a short explanation for users, not intended to be | 31 /// The message is a short explanation for users, not intended to be |
32 /// machine-readable. | 32 /// machine-readable. |
33 Abort { | 33 Abort { |
34 message: String, | 34 message: String, |
35 detailed_exit_code: exit_codes::ExitCode, | 35 detailed_exit_code: exit_codes::ExitCode, |
36 hint: Option<String>, | |
36 }, | 37 }, |
37 | 38 |
38 /// A configuration value is not in the expected syntax. | 39 /// A configuration value is not in the expected syntax. |
39 /// | 40 /// |
40 /// These errors can happen in many places in the code because values are | 41 /// These errors can happen in many places in the code because values are |
80 } | 81 } |
81 | 82 |
82 pub fn abort( | 83 pub fn abort( |
83 explanation: impl Into<String>, | 84 explanation: impl Into<String>, |
84 exit_code: exit_codes::ExitCode, | 85 exit_code: exit_codes::ExitCode, |
86 hint: Option<String>, | |
85 ) -> Self { | 87 ) -> Self { |
86 HgError::Abort { | 88 HgError::Abort { |
87 message: explanation.into(), | 89 message: explanation.into(), |
88 detailed_exit_code: exit_code, | 90 detailed_exit_code: exit_code, |
91 hint, | |
89 } | 92 } |
90 } | 93 } |
91 } | 94 } |
92 | 95 |
93 // TODO: use `DisplayBytes` instead to show non-Unicode filenames losslessly? | 96 // TODO: use `DisplayBytes` instead to show non-Unicode filenames losslessly? |