How do you prevent debug messages from displaying?
When I set my debug mode to Production...and a recoverable error occurs within the code, CakePHP will output the error details in the UI. How do I prevent this from displaying?
...debug config setting:
Configure::write('debug', 0);
...sample code to cause an error (within a controller action):
$myError = $something['NullExceptionGoes']['HERE'];
...this causes a cake-debug block to be added to the view (just below the beginning body tag):
error details will be output...i do not want users to see this info...i want to p开发者_如何学Crevent this block from being displayed
<pre class="cake-debug">
<a onclick="document.getElementById('cakeErr1-trace').style.display = (document.getElementById('cakeErr1-trace').style.display == 'none' ? '' : 'none');" href="javascript:void(0);"><b>Notice</b> (8)</a>
: Undefined variable: something [<b>APP/controllers/home_controller.php</b>, line <b>12</b>]
<div style="display: none;" class="cake-stack-trace" id="cakeErr1-trace">
<a onclick="document.getElementById('cakeErr1-code').style.display = (document.getElementById('cakeErr1-code').style.display == 'none' ? '' : 'none')" href="javascript:void(0);">Code</a> | <a onclick="document.getElementById('cakeErr1-context').style.display = (document.getElementById('cakeErr1-context').style.display == 'none' ? '' : 'none')" href="javascript:void(0);">Context</a><div style="display: none;" class="cake-code-dump" id="cakeErr1-code"><pre><code><span style="color: rgb(0, 0, 0);"> $this->set('title_for_layout', $title_for_layout);</span></code>
<code><span style="color: rgb(0, 0, 0);"></span></code>
<span class="code-highlight"><code><span style="color: rgb(0, 0, 0);"> $myvar = $something['nullexceptiongoeshere']['hello'];</span></code></span></pre></div>
<pre style="display: none;" class="cake-context" id="cakeErr1-context">$title_for_layout = "page title"</pre>
<pre class="stack-trace">HomeController::index() - APP/controllers/home_controller.php, line 12
Dispatcher::_invoke() - CORE/cake/dispatcher.php, line 204
Dispatcher::dispatch() - CORE/cake/dispatcher.php, line 171
[main] - APP/webroot/index.php, line 83</pre>
</div>
</pre>
You are probably overriding debug output in your controller method.
Verify that:
Configure::write('debug', x);
is not in your controller as well (where x = 1 or 2).
精彩评论