473,395 Members | 1,658 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Handling the error_handler

I've recently been looking into PHP's custom error handler support,
which seems to me to fail at exactly the point that you need it to start
working. I quote:

"Note: The following error types cannot be handled with a user defined
function: E_ERROR, E_PARSE, E_CORE_ERROR, E_CORE_WARNING,
E_COMPILE_ERROR and E_COMPILE_WARNING."

-- from http://au.php.net/manual/en/function...or-handler.php

How do I get PHP to email me when a *genuinely serious* error occurs?
Those, after all, are the ones that I really want to be told about. Is
there the PHP equivalent of an 'onAbort' hook anywhere?

Basically, I want to know what's gone wrong when it happens, rather than
needing to look through logfiles to see what went wrong in the past.

How do people normally do this?

Nigel Chapman,
Sydney Australia.

kale77in at hotmail * (don't reply to my [From:] address, it's bogus)

Jul 16 '05 #1
4 2563
"Nigel A. Chapman" <nc******@bigpond.com> writes:
How do I get PHP to email me when a *genuinely serious* error occurs?
Those, after all, are the ones that I really want to be told about.
Is there the PHP equivalent of an 'onAbort' hook anywhere?

Basically, I want to know what's gone wrong when it happens, rather
than needing to look through logfiles to see what went wrong in the
past.

How do people normally do this?


I have PHP set up to send its error messages through syslog to
/var/log/user.log

Then, I run the logcheck program hourly from cron, and get the
error messages emailed to me if any happened since the last run.

If you really needed almost instant notification, you could run
logcheck every five minutes - it's fairly lightweight.

Logcheck lets you set up a lot of good filtering so you only get
interesting stuff. I'd recommend using it in combination with a good
syslog program such as syslog-ng to make filtering easier.

--
Chris
Jul 16 '05 #2
Thanks, that's helpful. I'll fall back to that position unless I can
find something that doesn't require access to the server.

Chris Morris wrote:
I have PHP set up to send its error messages through syslog to
/var/log/user.log

Then, I run the logcheck program hourly from cron, and get the
error messages emailed to me if any happened since the last run.

If you really needed almost instant notification, you could run
logcheck every five minutes - it's fairly lightweight.

Logcheck lets you set up a lot of good filtering so you only get
interesting stuff. I'd recommend using it in combination with a good
syslog program such as syslog-ng to make filtering easier.


Jul 16 '05 #3
Tony Marston wrote:
"Note: The following error types cannot be handled with a user defined
function: E_ERROR, E_PARSE, E_CORE_ERROR, E_CORE_WARNING,
E_COMPILE_ERROR and E_COMPILE_WARNING."
Take a look at http://www.tonymarston.net/php-mysql/errorhandler.html
which shows you how to create an error handler which will send an
email if a fatal error is encountered.


I'll give it a run, but I don't see from your code how your
user-defined-error function gets around the above-mentioned limitation
in PHP. Does it really respond to parsing errors?

--

Nigel Chapman,
Sydney Australia.

kale77in at hotmail * (don't reply to my [From:] address, it's bogus)

Jul 16 '05 #4
"Nigel A. Chapman" <nc******@bigpond.com> wrote in message news:<p8******************@news-server.bigpond.net.au>...
Tony Marston wrote:
"Note: The following error types cannot be handled with a user defined
function: E_ERROR, E_PARSE, E_CORE_ERROR, E_CORE_WARNING,
E_COMPILE_ERROR and E_COMPILE_WARNING."

Take a look at http://www.tonymarston.net/php-mysql/errorhandler.html
which shows you how to create an error handler which will send an
email if a fatal error is encountered.


I'll give it a run, but I don't see from your code how your
user-defined-error function gets around the above-mentioned limitation
in PHP. Does it really respond to parsing errors?


No. If a parsing error occurs then your script won't even run (this
will be detected when you test your script). My error handler will
trap runtime errors.

Try using it, and force a few runtime errors just to see what happens.

Tony Marston
http://www.tonymarston.net/
Jul 16 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: WSeeger | last post by:
When creating a new class, is it encouraged to always include error handling routines within your LET and GET procedures? It's seems that most text books never seem to include much about error...
9
by: Hans-Joachim Widmaier | last post by:
Hi all. Handling files is an extremely frequent task in programming, so most programming languages have an abstraction of the basic files offered by the underlying operating system. This is...
3
by: Master of C++ | last post by:
Hi, I am an absolute newbie to Exception Handling, and I am trying to retrofit exception handling to a LOT of C++ code that I've written earlier. I am just looking for a bare-bones, low-tech...
21
by: Anthony England | last post by:
Everyone knows that global variables get re-set in an mdb when an un-handled error is encountered, but it seems that this also happens when the variable is defined as private at form-level. So...
3
by: Stefan Johansson | last post by:
Hi all I'am moving from Visual Foxpro and have a question regarding "best practice" error handling in vb .net. In VFP I have always used a "central" error handling object in order to have a...
4
by: Al Williams | last post by:
Hi, I have error handling in place throughout my application. I also start the application wrapped in error handling code to catch any unexpected exceptions (i.e. exceptions that occur where I...
9
by: Gustaf | last post by:
I'm confused about structured error handling. The following piece of code is a simplification of a class library I'm working on. It works, and it does what I want, but I'm still not convinced that...
0
by: Lysander | last post by:
Thought I would give something back with a few articles. This article is a bit of code to add error handling. When I have time, I want to write articles on multilingual databases, and Access...
5
by: Rghertner | last post by:
Hi all, I've been away from Access error handling for a while, and now that I've returned I can't figure out what I'm doing wrong here. The following code doesn't pick up the error when there...
9
by: Daniel Smedegaard Buus | last post by:
Hey all :) I was wondering about the $error_types (I particularly notice the 's' suffix when reading the manual) parameter for 'set_error_handler()': Can be used to mask the triggering of the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.