Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Suppress PHP warnings for expected Oracle exceptions

I have a PHP function that calls a PL/SQL package that can throw a number of known exceptions (i.e. user exceptions) that I can catch in PHP and act on. The problem is, despite catching the exception in PHP I get a warning in the PHP log file with a stack trace from the PL/SQL exception:

PHP Warning:  oci_execute(): ORA-20001: Something isn't valid
ORA-234565: at "MY.PACKAGE", line 234
ORA-923485: at "MY.PACKAGE", line 123

How can I suppress these OCI warnings? I don't want to suppress all warnings as they can be helpful for other issues, but when it's an expected error from my PL/SQL I don't want it filling up my log file.

like image 677
Stephen Avatar asked Jun 01 '11 20:06

Stephen


1 Answers

If you only need to suppress the warning on oci_execute(), prepend it with @

@oci_execute()

Using that kind of runtime error suppression is often not recommended since it covers up problems in the application, but you've handled the problem in the code by catching the exception already and understand the consequence of suppressing the warnings.

PHP docs on the @ operator...

like image 179
Michael Berkowski Avatar answered Oct 03 '22 01:10

Michael Berkowski