That's probably not "best practice", but you could just enclose the failing call to send_basic_header in a try {...} block (and check $@ afterwards), then at least not your whole app will die.
Thanks for your help.
Like you said, I tried putting a try block around the send_basic_header code. Unfortunately, the $@ is '' and the process still dies..