It was debug difficult of an error occurred by after handle pipeline
Moln opened this issue · 2 comments
Moln commented
Code to reproduce the issue
It was difficult for us to debug error/exception, when an error/exception occurred by after handle pipeline.
These are situations that may occur.
- Output has been emitted previously.
- When I have a config file and there is no
declare(strict_types=1)
and exists UTF8+BOM. - Echo something in middleware or handler.
- etc..
- When I have a config file and there is no
- Throw an errors/exceptions in
ErrorHandler
's listeners.- When I attach a logger listener, and logging error.
- etc..
There will output an empty response (status 200). Then, we don't know what happened.
Expected results
Output messages by Whoops.
Actual results
Response OK (status code 200). And no error/exception outputed.
Suggestions
Remove $whoops->writeToOutput(false)
in WhoopsFactory
.
And add disable/enable send on both sides of get handleException
result.
zend-expressive/src/Middleware/WhoopsErrorResponseGenerator.php
Lines 82 to 84 in 491da1e
$sendOutput = $this->whoops->writeToOutput();
$this->whoops->writeToOutput(false);
$response
->getBody()
->write($this->whoops->handleException($e));
$this->whoops->writeToOutput($sendOutput); //Restore to write to output.
weierophinney commented
@Moln would you be willing to create a pull request based on your suggestion?
Moln commented
@weierophinney Yeah, I created.