Skip to content

Commit 8f31ee0

Browse files
author
Bonnia
authored
Update error.rs
Only a Fix some things and improve stuff codes on error file
1 parent ce36a96 commit 8f31ee0

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/librustdoc/error.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,26 @@ pub(crate) struct Error {
99
pub(crate) file: PathBuf,
1010
pub(crate) error: String,
1111
}
12+
//note for that as change some codes here
13+
//Make Changes if You know
1214

1315
impl error::Error for Error {}
1416

1517
impl std::fmt::Display for Error {
1618
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
17-
let file = self.file.display().to_string();
18-
if file.is_empty() {
19-
write!(f, "{}", self.error)
19+
if let Some(file) = self.file.to_str() {
20+
if file.is_empty() {
21+
write!(f, "Error: {}", self.error)
22+
} else {
23+
write!(f, "File: \"{}\", Error: {}", file, self.error)
24+
}
2025
} else {
21-
write!(f, "\"{}\": {}", self.file.display(), self.error)
26+
write!(f, "Error: {}", self.error)
2227
}
2328
}
2429
}
2530

31+
2632
impl PathError for Error {
2733
fn new<S, P: AsRef<Path>>(e: S, path: P) -> Error
2834
where

0 commit comments

Comments
 (0)