Skip to content

Commit b44e8f2

Browse files
Failure to prettify log is not a fatal error
1 parent d156f25 commit b44e8f2

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

site/src/server.rs

+9-6
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,14 @@ pub fn handle_dashboard(data: &InputData) -> dashboard::Response {
227227
}
228228
}
229229

230+
fn prettify_log(log: &str) -> Option<String> {
231+
let mut lines = log.lines();
232+
let first = lines.next()?;
233+
let log = &first[first.find('"')? + 1..];
234+
let log = &log[..log.find("\" }")?];
235+
Some(log.replace("\\n", "\n"))
236+
}
237+
230238
pub fn handle_status_page(data: &InputData) -> status::Response {
231239
let last_commit = data.data(Interpolate::No).iter().next_back().unwrap();
232240

@@ -235,12 +243,7 @@ pub fn handle_status_page(data: &InputData) -> status::Response {
235243
.iter()
236244
.map(|(name, res)| {
237245
let msg = if let Some(error) = res.as_ref().err() {
238-
let mut lines = error.lines();
239-
let first = lines.next().unwrap();
240-
let log = &first[first.find('"').unwrap() + 1..];
241-
let log = &log[..log.find("\" }").unwrap()];
242-
let log = log.replace("\\n", "\n");
243-
Some(log)
246+
Some(prettify_log(error).unwrap_or_else(|| error.to_owned()))
244247
} else {
245248
None
246249
};

0 commit comments

Comments
 (0)