I'm writing a function that I would like to respond to the same error conditions by both die()ing and exiting with specific exit codes. Is there a way to set the exit code with die?
Here's why I want this. I'm writing some nagios plugins. Nagios plugins are scripts that communicate broad status informaion with the script's exit code, and detailed status information with STDOUT. I'm writing several of these things and I'm trying to re-use my code by putting it into modules. Sometimes, I want to catch certain errors and other times I want the same errors to make the script die. If I use die(), I can't set the exit code, so I can't communicate the broad status info. If I use exit(), I can't catch the error.
Thanks!
-Pileofrogs