tony / oxwm

Removed the use of strings in the MainError Debug implementation Browse files
Scott DeJong committed 2025-12-19 parent 0d527c6 commit 19b2885beda247bbfcc1c493cabd1f9ccdf2fb1a
Showing 1 changed file with 10 additions and 11 deletions. UnifiedSplit
+10 −11 src/errors.rs
@@ -193,21 +193,20 @@ impl std::fmt::Debug for MainError {
193 193 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
194 194 use MainError::*;
195 195
196 - let message = match self {
196 + match self {
197 197 CouldNotCreateConfigDir(e)
198 198 | CouldNotWriteConfig(e)
199 199 | FailedCheckExist(e)
200 200 | FailedReadConfig(e) => {
201 - format!("{e}")
201 + write!(f, "{e}")
202 202 }
203 - FailedReadConfigTemplate(e) => format!("{e}"),
204 - CouldNotStartWm(e) | BadRestartStatus(e) => format!("{e}"),
205 - BadConfigPath => "Given config path does not exist".to_string(),
206 - NoConfigPath => "The --config switch requires a path value".to_string(),
207 - InvalidArguments => "The arguments given are invalid try --help".to_string(),
208 - NoProgramName => "Could not get the program name from the environment".to_string(),
209 - NoConfigDir => "Could not get the config dir".to_string(),
210 - };
211 - write!(f, "{message}")
203 + FailedReadConfigTemplate(e) => write!(f, "{e}"),
204 + CouldNotStartWm(e) | BadRestartStatus(e) => write!(f, "{e}"),
205 + BadConfigPath => write!(f, "Given config path does not exist"),
206 + NoConfigPath => write!(f, "The --config switch requires a path value"),
207 + InvalidArguments => write!(f, "The arguments given are invalid try --help"),
208 + NoProgramName => write!(f, "Could not get the program name from the environment"),
209 + NoConfigDir => write!(f, "Could not get the config dir"),
210 + }
212 211 }
213 212 }