I am doing a lot of tests with ExeOutput and I love the product!
I just encountered one problem which I would like to solve.
In case of a PHP error (typo, missing semicolon, coding error) I just get a blank white screen.
With having php logging enabled I can easy find the root cause and fix it but a blank website is not really user friendly.
Would it be possible to just style this blank website by myself with a message âwhops something went wrong - please restart the toolâ or do some PHP actions to redirect the user to a side which works for 100% to get the tool working again?
That would be a bit more userfriendly instead of showing a white screen in case of an error
How to reproduce:
create a php file with the following content and then let it compile to an exe:
Wow! That was a quick fix!
May I ask what exactly will be possible by this implementation?
Can I only style some text or would it be possible to just link to another PHP website?
Can the error be stored in a specific variable? If yes it would be possible to allow something like: âSomething went wrong - do you want to transfer the error data to the developerâ or you can display the PHP error in a good looking template so the customer could forward a screenshot.
Great feature. I have struggled to find unique ways to catch those errors and display a custom message but all were wonky. This will be a welcome feature. Thank you support and @MatthiasB for bringing it alive.
ExeOutput for PHP now displays the standard error page instead of a white page. The error page can be customized in the âDialog Boxesâ tab of ExeOutput. So basically you can customize the entire HTML code and include your own CSS.
I am currently playing with this new functionality.
Within the Error message dialog IâVe put in the following content:
Then within the errorhandling.php I set the following text to work with the error:
exo_getglobalvariable (âhelasterrormessageâ, âUndefined errorâ);
I want to go this way since I would like to use php code to handle the error which is not possible in the html error dialog.
Unfortunately the helasterrormessage variable is always empty. Am I doing something wrong?
If itâs a PHP error message, try to read this global variable instead: lastphperror
exo_getglobalvariable (âlastphperrorâ, âUndefined errorâ);
Thanks for the fast response.
I found my problem which was the missing âechoâ lol
The following code works:
$error = exo_getglobalvariable (âhelasterrormessageâ, âUndefined errorâ);
echo $error;
Your mentioned code always delivers âUndefined errorâ.
But I found 2 more points where I am not sure if these are expected limitations or something which can be sorted by configuration.
Point 1
For the following code I would expect 2 errors:
if($a==â1â){
echo âtestâ;
}
echo âblubâ
return $smarty->fetch(âtest.htmâ);
$a is not defined
the missing â;â
In case that I add the â;â then the error 1) is shown. In case that I remove the â;â then only the error message for the â;â is shown.
I would expect both error messages should be shown.
Point 2
In some cases I get the following message:
PHP Error: Error stored in php_errors.log file in EXE folder, provided that you enabled PHP error logging (in âPHP Settings / Debuggingâ in ExeOutput for PHP).
I have not found out yet under which condition this message is thrown. Looking into the php_errors.log then I can see 6x âPHP Notice: Undefined index:â messages. I would prefer to have this outcome instead of the generic message. Usually in production environment the php_errors.log is disabled.
maybe there is a misunderstanding
In some cases I get the following error message:
PHP Error: Error stored in php_errors.log file in EXE folder, provided that you enabled PHP error logging (in âPHP Settings / Debuggingâ in ExeOutput for PHP).
To me this looks like a message created by ExeOutput. Instead of this generic message I would like to receive the real php error which is the reason for this message.
The real error message is stored in the âphp_errors.logâ file (provided that the PHP error logging option (in âPHP Settings / Debuggingâ in ExeOutput for PHP) is checked.
yes, this is understood
For development purpose and troubleshooting this is perfectly fine but when I deliver a software to my customer then I want to turn this logging functionality off.
With the new devlopment to style the error page I do a redirect to an internal page. This internal page gives a feedback to the user that something went wrong and that the user does have the chance to forward the information to the software vendor. He can only click a âSend debug infoâ button.
When he clicks the button then the php error message is sent via JSON to my server so I can analyze and investigate.
In case of a basic error like
echo "hello; // missing "
this works perfect as I can see the php error and directly fix it.
In some cases I get the message
PHP Error: Error stored in php_errors.log file in EXE folder, provided that you enabled PHP error logging (in âPHP Settings / Debuggingâ in ExeOutput for PHP).
This does not help me since I do not have the php_errors.log file. This would require me to create a specific debugging file for my customer which is not so professional as if I could simply grab the error.
Some customer I do not know in person so this just even makes it more difficult.
This is the reason why I would like to have the error directly inside the application and not in a separate file.
I hope this makes sense.
I think I understand your need better (I havenât tested the new error page management style yet).
If Iâm not mistaken, the âSend debug infoâ button sends (or tries to send) the âerror messageâ and not the âphp_error.txtâ file (which contains until now in my tests, the real error message). As a result, for some errors, you get the message :
PHP Error: Error stored in php_errors.log file in EXE folder, provided that you enabled PHP error logging (in âPHP Settings / Debuggingâ in ExeOutput for PHP)."
Right?
Personally I was planning to use the new style which replaces the white page in case of error, by the new stylized page to display in Front, a significant message (as already proposed), and in Back-End to send the file php_error.txt via phpMail (for example) in file attachment since I know the location of the file (which I would prefer moreover to have it in the folder âData/logâ for example since easier to communicate via php with the Data folder recognized as root". And make sure to delete the file if it exists, every time I start the app, so I donât drag a file with old reports.
But if itâs possible to have the file sent by the app itself, I wouldnât be against it either .
And this result is something I can then send via JSON, email or whatever I like.
I do not want the php_error.log to be stored somewhere as this would give the chance to get more insights of the tool I developed. Also it might interfere with antivirus for example when it tries to access or delete the file.
As a side note I found out that as soon as you enable the php_error.log the enduser will not be redirected to the error page when above mentioned error message appears so you could not catch it. I am not sure if this behavior is by design.
I myself for the moment do not activate php_error.log in production for the same reason as mentioned. I usually just leave a form in a report section to describe what went wrong in order to try to reproduce the potential bug in dev (not very practical and professional).
Thatâs why I was planning to do as said above provided that I could efficiently : Generate, retrieve and delete the log file in backend without giving the opportunity (at best possible XD) to the end user to see this file. I didnât think about the potential interference with antivirus since I didnât have these cases until now .
I will keep an eye on this subject in case a better solution (existing or to come) is proposed.
maybe this ticket got lost in the queue. Today I got a new âcrash reportâ from my app so I wanted to find out what went wrong.
Unfortunately the error message which was returned was just as follows:
PHP Error: Error stored in php_errors.log file in EXE folder, provided that you enabled PHP error logging (in âPHP Settings / Debuggingâ in ExeOutput for PHP)."
Therefore I had to call my customer to ask what he did. He just filled out a form and left some fields empty.
This would easily be visible in the php error log.
Any chance to return the errors instead of this generic message above?