Skip to content

Commit

Permalink
Move stack overflow message to constant
Browse files Browse the repository at this point in the history
  • Loading branch information
jfrimmel committed Sep 22, 2024
1 parent a4fe601 commit 28a37a5
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ use colored::Colorize as _;
use std::env;
use std::process;

/// Part of the output message of `valgrind` if a possible stack overflow is
/// detected.
const STACK_OVERFLOW: &str = "main thread stack using the --main-stacksize= flag";

fn main() {
panic::replace_hook();

Expand Down Expand Up @@ -75,9 +79,7 @@ fn main() {
Err(e @ valgrind::Error::MalformedOutput(..)) => {
panic_with!(e);
}
Err(valgrind::Error::ValgrindFailure(output))
if output.contains("main thread stack using the --main-stacksize= flag") =>
{
Err(valgrind::Error::ValgrindFailure(output)) if output.contains(STACK_OVERFLOW) => {
output::display_stack_overflow(&output);
134 // default exit code for stack overflows
}
Expand Down

0 comments on commit 28a37a5

Please sign in to comment.