How can be disable exception messages on the production website and keep them in dev?
Example:
try{
//some code
}
catch(Exception $e){
echo $e.getMessage();
}
Edit:
How it done on Zend Framework? (.ini file but what about exception code that should be write?)
Edit 2:
If my example can’t work how zend framework disable exception messages in application.ini?
resources.frontController.params.displayExceptions = 0
I’m not sure if we are getting you right.
The other answers tell how whether to throw or not the Exception regarding the environment setting.
The answer is simple:
The exceptions should be thrown always, not regarding the environment.
If you need, you may handle them differently, but you should avoid conditional exceptions.
There are many ways, you may set up error handling in your app:
.htaccessconfigerror_reporting())application.inior getting front controller instance inBootstrap)The simplest it seems is
application.ini:In development section of
application.iniyou may use zeros where needed.I recommend using Log Application resource to handle the exceptions on the production environment.