-
-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Keeping ErrorHandler::class in ZE3 pipeline.php hides descriptive error messages #49
Comments
ErrorHandler::class
in ZE3 pipeline.php hides descriptive error messages
I tried with php 7.2, latest expressive 3 skeleton, latest
<?php
// config/autoload/local.php
return [
'db' => [
'username' => 'root',
'password' => '',
'driver' => 'pdo_mysql',
'database' => 'expressive',
'host' => 'localhost',
'driver_options' => [
\PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES \'UTF8\'',
],
],
];
// config/pipeline.php
$app->pipe(ErrorHandler::class);
$app->pipe(ErrorHeroModule\Middleware\Expressive::class);
public function handle(ServerRequestInterface $request) : ResponseInterface
{
throw new \Exception('test');
}
If removing register of |
Thanks @samsonasik. I have updated my First, I am guessing whatever I had in my config did not trigger the module (ErrorHeroModule), so instead Second, with ErrorHeroModule I saw that the SQL command being executed was:
Which gave error of:
After fixing that, I see that:
What I mean by explicit error, is PHP's native output and exactly what is being written to the log. i.e. :
I was expecting to see that level of detail rather than "We have encountered a problem..." |
// config/autoload/error-hero-module.local.php
'log' => [
'ErrorHeroModuleLogger' => [
'writers' => [
[
'name' => 'db',
'options' => [
// ... current config
'formatter' => [
'name' => 'db',
'options' => [
'dateTimeFormat' => 'Y-m-d H:i:s',
],
],
// ...
],
],
],
],
],
|
Thanks,
Setting it to 1 goes back to showing my layout with this non-descriptive error message in browser:
setting
It only shows the descriptive error I was looking for in the database log. Is that the expected behavior? |
Actually, removing : Yes, set the |
I think it depends on the type of error. In my case I did not supply enough parameters to a method when the method expected a certain number of them. With a different type of error, such as having raw output in a Handler, I do see the error messages on the screen. i.e:
Exact behavior probably depends on the type of error. |
What ZF application I'm using when issue happen ?
What PHP version you're using?
What ErrorHeroModule version you're using?
What Database you're using?
Expected behavior
Upon a PHP error, show a meaningful descriptive error message from PHP, pointing to the root cause of web page malfunction. i.e.
Fatal error: [description ... ].
Actual behavior
Browser displays the following message:
There are no further clues to the error message in the Apache error log. There is nothing in Mozilla's Developer Tools. Nothing seems to get logged via the
ErrorHeroModuleLogger
in the database table.Steps/Codes to reproduce the behavior
In my
pipeline.php
I have the following:I suspect that whatever the error is, it gets eaten up by the
ErrorHandler::class
and the generic message above is displayed, hiding the real error description.Potential Solution: Removing the
ErrorHandler::class
frompipeline.php
uncovers the descriptive error and displays the full error message from PHP that I am looking for.Summary
It seems to me that the line of
$app->pipe(ErrorHandler::class)
is the culprit in covering up descriptive error messages. Removing it resolves my immediate issue and shows me the descriptive errors I was looking for. CanErrorHandler::class
be removed? Must it remain in Expressive pipeline config and if yes can I still see descriptive error messages?The text was updated successfully, but these errors were encountered: