Lisa
Lisa

Reputation: 2139

Custom PHP Error Handling

I'm running into an...irritation, I guess...with a custom error handler in the application I work with, and I'm hoping someone here can offer some insight.

As part of the data aggregation for our site, custom spiders and parsers are built on an individual basis outside of our codebase. They're stored in the database and run via eval inside of a gearman process.

There's a custom error handler set up that inserts the ID number of the company being run if there's an error (like if a delimiter is forgotten in a regular expression, or there's a divide by zero error when I haven't had my coffee). For the most part, this error handler works great.

However, I've noticed that if there is an unterminated comment in the eval'd code, the error handler isn't used, so the php error logs don't contain the ID number of the company with the issue.

We handle the following error types in the handler

The logs state that the comment string error is 'Warning', so I don't know why the custom hanlder isn't being invoked.

Any thoughts?

Upvotes: 0

Views: 97

Answers (1)

nietonfir
nietonfir

Reputation: 4881

According to the documentation you can't use a custom function as error_handler() for E_ERROR:

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, E_COMPILE_WARNING, and most of E_STRICT raised in the file where set_error_handler() is called.

Upvotes: 1

Related Questions