I am trying to find a place where an error occurs in my project to be able to throw an error message from there.
Within the project I am debugging, an ajax post call is executed. Somewhere earlier in PHP the code causing the error is executing. In my case, a parse error
is causing the problem. An array value is tried to be fetched out of a boolean variable. But at that place, nothing goes wrong and the code continues to run.
Failing PHP code:
if ($booleanValue['not-existing-arrayvalue'] == 'true') { }
The ajax code that is been called at some point:
var call = $.ajax(options);
call.done(function (result) { ... })
.fail(function(xhr, text_status){ ... }
Inside of the fail method, the error becomes clear, but it is stored within a huge html response, so hard to fetch from the whole value. It is stored within xhr.responseText:
<br />↵<font size='1'><table class='xdebug-error xe-notice' dir='ltr' border='1' cellspacing='0' cellpadding='1'>↵<tr><th align='left' bgcolor='#f57900' colspan="5"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> Notice: Undefined index: selected in "C:\workspace\project\class.php" on line <i>14</i></th></tr>↵<tr><th align='left' bgcolor='#e9b96e' colspan='5'>Call Stack</th>
This is just a part of the value, containing the line number causing the error.
Does anybody have an idea where this ajax failing response text comes from and if it is possible to get a cleaner message instead of a big html output string?