Thursday, November 8, 2007

Error Handling.. Mail server bashing

As my last post suggested, I've been working on error handling.

To finally put things in order, and stop error messages from showing up anywhere at all (although I think I've decided to put them back into pages for the dev servers at least), I put together a super simple function that captures the errors, and sends me an email.

error_reporting(0);
function myErrorHandler($errno, $errmsg, $filename, $linenum, $vars)
{
$dt = date("Y-m-d H:i:s (T)");
$errortype = array (
E_ERROR => 'Error',
E_WARNING => 'Warning',
E_PARSE => 'Parsing Error',
E_NOTICE => 'Notice',
E_CORE_ERROR => 'Core Error',
E_CORE_WARNING => 'Core Warning',
E_COMPILE_ERROR => 'Compile Error',
E_COMPILE_WARNING => 'Compile Warning',
E_USER_ERROR => 'User Error',
E_USER_WARNING => 'User Warning',
E_USER_NOTICE => 'User Notice',
E_STRICT => 'Runtime Notice',
E_RECOVERABLE_ERROR => 'Catchable Fatal Error'
);
$user_errors = array(E_USER_ERROR, E_USER_WARNING, E_USER_NOTICE);
$err = "Error.\n";
$err .= "\tDate: " . $dt . "\n";
$err .= "\tError Num: " . $errno . "\n";
$err .= "\tError Type: " . $errortype[$errno] . "\n";
$err .= "\tError msg: " . $errmsg . "\n";
$err .= "\tScript name: " . $filename . "\n";
$err .= "\tScript line num: " . $linenum . "\n";
$err .= "\n\n";

// if ($errno == E_WARNING) {
mail("something@gmail.com", "Critical Site Error", $err);
// }
}
$old_error_handler = set_error_handler("myErrorHandler");

I realise it sends me a bazillion emails when I'm not limiting it warnings or errors, but it's alright now, I setup a gmail account to handle it all.
I actually got a stern email, followed by a stern phone call from IS.. they said I was "causing emails to bounce" because of the volume I was getting from the server. So incredibly pathetic imo.. even iMail over at Impress could handle it.. c'mon.. like 120 emails an hour.. that's NOTHING!!!

Anyhow.. volume on those emails has gone down as I've fixed the obvious stuff. I guess once I get it down to one or two a day, I'll switch it back to my actual work account email for real emergencies.

BFN

4 comments:

Bruno Cardoso said...

Not really commenting the post.

Just wanted to say: "Hi! Long time no see."

Hope you're doing well.

Stay safe! =)

morjana said...

I've been looking for an e-mail address for the MGM Stargate site...or any MGM site. They seem to have all vanished, and when I try "webmaster@" the e-mail is returned as undeliverable.

Would you happen to know of any that are viable?

And thank YOU for all your hard work on the MGM Stargate site. Really nice to see that site updated so quickly!

Best wishes, Morjana

Unknown said...

Hi Bruno! So great to hear from you! I pop by your site every so often to see what you're up to, hope you're well!

Hi Morjana! I'm sorry I'm pretty sure there is no email for the website, there used to be one, .. let me see if I can find out if there's one now. We pretty much only take care of things that are actually broken with the website, we're extremely far removed from show production & TPTB. I find out more reading Gateworld!

Unknown said...

Not sure how to get ahold of you without posting another comment, so here is what I found out about our email addresses:

You're right.. for some reason webmaster@mgm.com is a no-go. comments at mgm.com seems to be your best bet, although I know it's not closely monitored, and it gets a lot of spam (not from people, literally spam about viagra and such) so it takes a while before someone will get back to you.
Or you can email me! I'd be happy to give you my email, but not in comments :) I could msg you on myspace?