Skip to content

Commit

Permalink
inline_panic
Browse files Browse the repository at this point in the history
  • Loading branch information
epompeii committed Jul 6, 2024
1 parent 659d077 commit 8756789
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions services/api/src/context/messenger/body/button.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,22 @@ impl FmtBody for ButtonBody {
);

slog::debug!(log, "Inlining CSS into HTML");
match css_inline::inline(&html) {
Ok(html) => html,
if let Ok(inlined_html) = std::panic::catch_unwind(|| match css_inline::inline(&html) {
Ok(html) => Some(html),
Err(err) => {
slog::error!(log, "Failed to inline CSS: {err}");
#[cfg(feature = "sentry")]
sentry::capture_error(&err);
html
None
},
}) {
inlined_html.unwrap_or(html)
} else {
let msg = "Panicked trying to inline CSS";
slog::error!(log, "{msg}");
#[cfg(feature = "sentry")]
sentry::capture_message(msg, sentry::Level::Error);
html
}
}
}

0 comments on commit 8756789

Please sign in to comment.