0

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

  • E_WARNING
  • E_USER_WARNING
  • E_ERROR
  • E_USER_ERROR

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?

3
  • Do you use set_error_handler() to handle errors ? Commented Oct 22, 2013 at 20:49
  • just curious, could you add /**/\n at the end of all code? That would force terminate comments. Commented Oct 22, 2013 at 20:49
  • Unterminated coments aren't the only things causing weird issues, but it's the easiest to explain. Commented Oct 22, 2013 at 20:55

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

So if it's being put in the log as a Warning, I'm guessing it's a core or compile warning? Is there a way to tell what it is?
Sorry, not sure about that as I have xdebug installed on all my machines and my errors look like: PHP Parse error: syntax error, unexpected ')', expecting '(' in … on line 38, with a stack trace. You could try to implement the solution from the following question: stackoverflow.com/questions/277224/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.