From 8f31ee0af57325af1969921ea5fee84d291d4fe3 Mon Sep 17 00:00:00 2001 From: Bonnia Date: Tue, 18 Feb 2025 05:24:08 +0300 Subject: [PATCH] Update error.rs Only a Fix some things and improve stuff codes on error file --- src/librustdoc/error.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/librustdoc/error.rs b/src/librustdoc/error.rs index 7876125f7fdf7..893dab0e50e42 100644 --- a/src/librustdoc/error.rs +++ b/src/librustdoc/error.rs @@ -9,20 +9,26 @@ pub(crate) struct Error { pub(crate) file: PathBuf, pub(crate) error: String, } +//note for that as change some codes here +//Make Changes if You know impl error::Error for Error {} impl std::fmt::Display for Error { fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { - let file = self.file.display().to_string(); - if file.is_empty() { - write!(f, "{}", self.error) + if let Some(file) = self.file.to_str() { + if file.is_empty() { + write!(f, "Error: {}", self.error) + } else { + write!(f, "File: \"{}\", Error: {}", file, self.error) + } } else { - write!(f, "\"{}\": {}", self.file.display(), self.error) + write!(f, "Error: {}", self.error) } } } + impl PathError for Error { fn new>(e: S, path: P) -> Error where