3

I am trying to catch a runtime exception that will be thrown by a function that is basically just a wrapper function for oci_execute(). For example:

try {   
    $SQL = "INSERT";
    ExecuteQuery($SQL);
} catch (Exception $e) {
    echo "<p>There was an error.</p>";
    echo $e->getMessage();
}

However, the exception doesn't appear to be caught:

...
ociexecute() [function.ociexecute]: ORA-00925: missing INTO keyword
...

Am I missing something here?

1
  • Is your ExecuteQuery function really throwing an exception? Commented Aug 11, 2009 at 8:56

2 Answers 2

7

It looks like it's triggering an error rather than throwing an exception.

You could convert errors to exceptions using set_error_handler() - something like this:

function errorHandler($number, $string, $file = 'Unknown', $line = 0, $context = array())
{
    if (($number == E_NOTICE) || ($number == E_STRICT))
        return false;

    if (!error_reporting())
        return false;

    throw new Exception($string, $number);

    return true;
}

set_error_handler('errorHandler');
Sign up to request clarification or add additional context in comments.

2 Comments

If you want to convert errors into exceptions you may want to take a look at PHP's own ErrorException: docs.php.net/manual/en/class.errorexception.php
You are awesome Greg.
0

It doesn't seem like an Exception, more like a plain PHP error.

If it is, check if you have eAccelerator and what version you have. I had a problem a while ago, there was eAccelerator bug that didn't catch Exception and I had to turn it off :|

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.