错误处理 [英] Error handling
问题描述
无论如何都设置一个自定义错误处理程序,它实际上是一个类的
方法?即将类foo的方法eh()设置为错误
处理程序在下面的代码段中。
class foo {
函数呃()
{做某事}
}
}
此外,怎么能我路由E_ERROR& E_PARSE错误到我的自定义
处理程序?我试过''error_reporting(E_ALL)''但是没用。
TIA
Hi,
Is there anyway to set a custom error handler which is actually a
method of a class? i.e. setting the method eh() of class foo as error
handler in the snippet below.
class foo {
function eh()
{ do something }
}
}
Further more, how can I route E_ERROR & E_PARSE errors to my custom
handler? I''ve tried ''error_reporting(E_ALL)'' but non avail.
TIA
推荐答案
Xeon写道:
无论如何设置自定义错误处理程序实际上是一个类的方法吗?即将类foo的方法eh()设置为错误
处理程序在下面的代码段中。
类foo {
函数eh()
{do something}
}
}
此外,我如何路由E_ERROR& E_PARSE错误到我的自定义处理程序?我试过''error_reporting(E_ALL)'但是没用。
TIA
Hi,
Is there anyway to set a custom error handler which is actually a
method of a class? i.e. setting the method eh() of class foo as error
handler in the snippet below.
class foo {
function eh()
{ do something }
}
}
Further more, how can I route E_ERROR & E_PARSE errors to my custom
handler? I''ve tried ''error_reporting(E_ALL)'' but non avail.
TIA
这是非常抽象的,我目前没有足够的资源来测试
它,但是这里有一个想法:
1.打开两个命名管道,一个用于stdout一个用于stderr
2.将stdout和stderr重定向到相应的命名管道
3.在eh()中,打开命名管道的文件句柄
4.处理错误。
这是完全未经测试的。我不知道这里会发生什么。
This is very abstract, and I currently don''t have the resources to test
it, but here''s an idea:
1. Open up two named pipes, one for stdout and one for stderr
2. Redirect stdout and stderr into the appropriate named pipes
3. In eh(), open a file handle to the named pipes
4. Handle said errors.
This is completely untested. I have no idea what will actually happen here.
在文章< 78 **************** *********@posting.google.com> ,
xd*****@zworg.com (Xeon)写道:
In article <78*************************@posting.google.com> ,
xd*****@zworg.com (Xeon) wrote:
无论如何设置自定义错误处理程序实际上是一个类的方法吗?即将类foo的方法eh()设置为错误
处理程序在下面的代码段中。
类foo {
函数eh()
{do something}
}
}
此外,我如何路由E_ERROR& E_PARSE错误到我的自定义处理程序?我已经尝试了''error_reporting(E_ALL)'但无效。
Is there anyway to set a custom error handler which is actually a
method of a class? i.e. setting the method eh() of class foo as error
handler in the snippet below.
class foo {
function eh()
{ do something }
}
}
Further more, how can I route E_ERROR & E_PARSE errors to my custom
handler? I''ve tried ''error_reporting(E_ALL)'' but non avail.
您是否已阅读手册中有关错误处理的章节< http:/ /php.net/errorfunc> ;?您可能会发现查看PEAR_error例程以获取有用的示例很有帮助。
什么是可能的。 < http://pear.php.net/package-info.php?package = PEAR>
-
CC
Have you read the manual''s chapter on error handling <http://php.net/errorfunc>? You may find it helpful to look at the PEAR_error routines for examples
of what''s possible. <http://pear.php.net/package-info.php?package=PEAR>
--
CC
为什么你的错误处理程序必须是类中的方法?
错误处理是一个单独的进程,所以创建一个类
使用单一方法是完全矫枉过正的。您可以在标准功能中实现所需的所有错误
hanfling。请参阅
http://www.tonymarston。 net / php-mysql / errorhandler.html 工作
的例子。
坚持认为一切都必须是班级的程序员让我疯狂。
并不总是最好的方法。
Tony Marston
http://www.tonymarston.net/
xd **** *@zworg.com (Xeon)在消息新闻中写道:< 78 ************************* @ posting.google。 c om> ...
Why on earth does your error handler have to be a method in a class?
Error handling is a single stand-alone process so creating a class
with a single method is total overkill. You can achieve all the error
hanfling you want in a standard function. Take a look at
http://www.tonymarston.net/php-mysql/errorhandler.html for a working
example.
Programmers who insist that everything must be a class drive me nuts.
It is not always the best method.
Tony Marston
http://www.tonymarston.net/
xd*****@zworg.com (Xeon) wrote in message news:<78*************************@posting.google.c om>...
无论如何设置自定义错误处理程序实际上是一个类的方法吗?即将类foo的方法eh()设置为错误
处理程序在下面的代码段中。
类foo {
函数eh()
{do something}
}
}
此外,我如何路由E_ERROR& E_PARSE错误到我的自定义处理程序?我试过''error_reporting(E_ALL)'但是没用。
TIA
Hi,
Is there anyway to set a custom error handler which is actually a
method of a class? i.e. setting the method eh() of class foo as error
handler in the snippet below.
class foo {
function eh()
{ do something }
}
}
Further more, how can I route E_ERROR & E_PARSE errors to my custom
handler? I''ve tried ''error_reporting(E_ALL)'' but non avail.
TIA
这篇关于错误处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!