From 28a37a5ac0403d60540f3b3e214b44cbcb8d3aa3 Mon Sep 17 00:00:00 2001 From: Julian Frimmel Date: Sun, 22 Sep 2024 21:03:20 +0200 Subject: [PATCH] Move stack overflow message to constant --- src/main.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index 2cc5628..160973b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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(); @@ -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 }