I am using CakePHP and sometimes something goes wrong and I get a wall of error text.
E.g.
$response = array(
'error'=>true,
'invalidKey'=>false,
'message'=>ERROR_ACCOUNT_EXISTS,
);
I have this code and let's say ERROR_ACCOUNT_EXISTS is not defined anywhere. It should throw an exception.
Here is what I get:
<pre class="cake-error"><a href="javascript:void(0);" onclick="document.getElementById('cakeErr55ad1d63b99ac-trace').style.display = (document.getElementById('cakeErr55ad1d63b99ac-trace').style.display == 'none' ? '' : 'none');"><b>Notice</b> (8)</a>: Use of undefined constant MESSAGE_REGISTRATION_SUCCESSFUL - assumed 'MESSAGE_REGISTRATION_SUCCESSFUL' [<b>APP/Controller/ApiController.php</b>, line <b>56</b>]<div id="cakeErr55ad1d63b99ac-trace" class="cake-stack-trace" style="display: none;"><a href="javascript:void(0);" onclick="document.getElementById('cakeErr55ad1d63b99ac-code').style.display = (document.getElementById('cakeErr55ad1d63b99ac-code').style.display == 'none' ? '' : 'none')">Code</a> <a href="javascript:void(0);" onclick="document.getElementById('cakeErr55ad1d63b99ac-context').style.display = (document.getElementById('cakeErr55ad1d63b99ac-context').style.display == 'none' ? '' : 'none')">Context</a><pre id="cakeErr55ad1d63b99ac-code" class="cake-code-dump" style="display: none;"><code><span style="color: #000000"><span style="color: #0000BB"> </span><span style="color: #DD0000">'invalidKey'</span><span style="color: #007700">=></span><span style="color: #0000BB">false</span><span style="color: #007700">,</span></span></code><code><span style="color: #000000"><span style="color: #0000BB"> </span><span style="color: #DD0000">'user'</span><span style="color: #007700">=></span><span style="color: #0000BB">$result</span><span style="color: #007700">[</span><span style="color: #DD0000">'User'</span><span style="color: #007700">],</span></span></code><span class="code-highlight"><code><span style="color: #000000"><span style="color: #0000BB"> </span><span style="color: #DD0000">'message'</span><span style="color: #007700">=> </span><span style="color: #0000BB">MESSAGE_REGISTRATION_SUCCESSFUL</span><span style="color: #007700">,</span></span></code></span></pre><pre id="cakeErr55ad1d63b99ac-context" class="cake-context" style="display: none;">$name = '
I do not want this kind of html error.
I have tried try catch clause but the result is the same.
How can I handle such errors?