php_ppt Posted March 3, 2011 Share Posted March 3, 2011 My script displays results until I hit an error. I continually get fatal timeout errors that I am unable to handle or ignore. Yes I googled and found the custom error handler AND the simpler try/catch. Still cant figure it out... It has been 1 hour of playing with this without success so I have to ask . Please help. thanks : ) try { if(($result=shell_exec("$commandLine")) == false) { echo "------>error"; throw new Exception; } else { echo "---->good"; } } catch (Exception $e) { echo "@@@__>exception caught"; } Quote Link to comment https://forums.phpfreaks.com/topic/229501-error-handling-newbie-needs-help/ Share on other sites More sharing options...
Muddy_Funster Posted March 3, 2011 Share Posted March 3, 2011 I suspect that's not the code that is causing the errors, where's the rest of the stuff? Quote Link to comment https://forums.phpfreaks.com/topic/229501-error-handling-newbie-needs-help/#findComment-1182468 Share on other sites More sharing options...
php_ppt Posted March 3, 2011 Author Share Posted March 3, 2011 I suspect that's not the code that is causing the errors, where's the rest of the stuff? The called code is going to time out and there is nothing I can do about that. I just want to be able to catch the timeOut error and continue with the PHP script. :'( Quote Link to comment https://forums.phpfreaks.com/topic/229501-error-handling-newbie-needs-help/#findComment-1182477 Share on other sites More sharing options...
php_ppt Posted March 4, 2011 Author Share Posted March 4, 2011 please delete thread.....reposted Quote Link to comment https://forums.phpfreaks.com/topic/229501-error-handling-newbie-needs-help/#findComment-1182792 Share on other sites More sharing options...
Maq Posted March 4, 2011 Share Posted March 4, 2011 please delete thread.....reposted Your other thread has been deleted due to this thread being the elder and having more responses. Please do not double post. Quote Link to comment https://forums.phpfreaks.com/topic/229501-error-handling-newbie-needs-help/#findComment-1182820 Share on other sites More sharing options...
Muddy_Funster Posted March 4, 2011 Share Posted March 4, 2011 ok....what is the function/procedure that is going to cause the time out?.....and why are you using it if you know it won't work? Quote Link to comment https://forums.phpfreaks.com/topic/229501-error-handling-newbie-needs-help/#findComment-1182831 Share on other sites More sharing options...
php_ppt Posted March 4, 2011 Author Share Posted March 4, 2011 please delete thread.....reposted Your other thread has been deleted due to this thread being the elder and having more responses. Please do not double post. ini_set ("display_errors", "1"); error_reporting(E_ALL); Thanks.....I did not mean to double post....I did request that this old one get deleted as it seemed to have stalled. Will avoid in future. I tried this and it did not work. ini_set ("display_errors", "1"); error_reporting(E_ALL); I found a couple of notes for "display_errors": Note: This is a feature to support your development and should never be used on production systems (e.g. systems connected to the internet). Note: Although display_errors may be set at runtime (with ini_set()), it won't have any affect if the script has fatal errors. This is because the desired runtime action does not get executed. I have read that fatal errors can be overcome. I have read that fatal errors cannot be overcome. ????? Quote Link to comment https://forums.phpfreaks.com/topic/229501-error-handling-newbie-needs-help/#findComment-1182854 Share on other sites More sharing options...
php_ppt Posted March 4, 2011 Author Share Posted March 4, 2011 ok....what is the function/procedure that is going to cause the time out?.....and why are you using it if you know it won't work? It usually works, I did not write it and I am not about to mess with the module that is also used by others. The script is calling an external function that is out of PHPs scope. It could be a Windows exe, a website or a unix box or some sitting in a cubicle pressing a red button. In BASH, VBS, C#, PERL and other languages these types of errors are expected and can be handled. I am thinking PHP has a way to deal with these types of errors but if it can't I have to find another less elegant and clunky way. ??????? Quote Link to comment https://forums.phpfreaks.com/topic/229501-error-handling-newbie-needs-help/#findComment-1182863 Share on other sites More sharing options...
Muddy_Funster Posted March 4, 2011 Share Posted March 4, 2011 well with that being the case, all I can suggest is that you could reverse your TRY statement, so that it checks for the criteria exactly matching and throws the exeption for everything else, and you could have a shot with using set_time_limit() to controll the timeout errors that way, But it's not something I have ever used, so I can't advise any more than that. Quote Link to comment https://forums.phpfreaks.com/topic/229501-error-handling-newbie-needs-help/#findComment-1182871 Share on other sites More sharing options...
php_ppt Posted March 4, 2011 Author Share Posted March 4, 2011 well with that being the case, all I can suggest is that you could reverse your TRY statement, so that it checks for the criteria exactly matching and throws the exeption for everything else, and you could have a shot with using set_time_limit() to controll the timeout errors that way, But it's not something I have ever used, so I can't advise any more than that. that will not work. set_time_limit() adds to the default time limit and returns a fatal error if exceeded. try/catch does nothing for fatal errors. If I could get the shell_exe() to give up before the max time limit without fatal error that would work but I have not come across anything that allows the shell_exe() to do so. ??????? Quote Link to comment https://forums.phpfreaks.com/topic/229501-error-handling-newbie-needs-help/#findComment-1182878 Share on other sites More sharing options...
kenrbnsn Posted March 4, 2011 Share Posted March 4, 2011 Did you read the manual page for the set_time_limit() function? There you will find: Parameters seconds The maximum execution time, in seconds. If set to zero, no time limit is imposed. and Note: The set_time_limit() function and the configuration directive max_execution_time only affect the execution time of the script itself. Any time spent on activity that happens outside the execution of the script such as system calls using system(), stream operations, database queries, etc. is not included when determining the maximum time that the script has been running. This is not true on Windows where the measured time is real. Ken Quote Link to comment https://forums.phpfreaks.com/topic/229501-error-handling-newbie-needs-help/#findComment-1182900 Share on other sites More sharing options...
php_ppt Posted March 4, 2011 Author Share Posted March 4, 2011 Did you read the manual page for the set_time_limit() function? There you will find: Parameters seconds The maximum execution time, in seconds. If set to zero, no time limit is imposed. and Note: The set_time_limit() function and the configuration directive max_execution_time only affect the execution time of the script itself. Any time spent on activity that happens outside the execution of the script such as system calls using system(), stream operations, database queries, etc. is not included when determining the maximum time that the script has been running. This is not true on Windows where the measured time is real. Ken I read: http://ca.php.net/manual/en/function.set-time-limit.php Where it states: Set the number of seconds a script is allowed to run. If this is reached, the script returns a fatal error. I do not want to exceed the set 30 second timelimit. I want it to run 30 seconds or less and fail with an error that allows the script to continue. From what I have seen/read/been told: Fatal errors will stop the script. ???????? Quote Link to comment https://forums.phpfreaks.com/topic/229501-error-handling-newbie-needs-help/#findComment-1182955 Share on other sites More sharing options...
php_ppt Posted March 6, 2011 Author Share Posted March 6, 2011 bump......still hoping to hear if this is a solvable issue and/or what items are needed to solve it. ????????? Quote Link to comment https://forums.phpfreaks.com/topic/229501-error-handling-newbie-needs-help/#findComment-1183549 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.