flow-development-collection
flow-development-collection copied to clipboard
BUGFIX: Web-Exception messages preserve whitespace (ASCII Art)
Closes #2696
Exceptions which have multiple spaces in their $message where previously not as expected displayed. Exceptions outputted to the CLI or logged did preserve multiple whitespaces naturally, but since they are collapsed in HTML by default, they are not shown in the browser.
- [x] Code follows the PSR-2 coding style
- [ ] Tests have been created, run and adjusted as needed
- [x] The PR is created against the lowest maintained branch
hmm could potentially harm readability - what do you think? But is also easy to change later again when its not ideal.
If using monospace font and white-space: pre in general leads to problems with readability, we could maybe introduce another (optional) property to the Flow exception base class that allows to render formatted strings (similar to statusCode)
i thought about additional optional properties on the exception too - but we took already a way different way - the 'a let flow handle this all automatic way': for example the exception message is splitt by some hacky regex into head and body: here and this is not configureable: https://github.com/neos/flow-development-collection/blob/0a19f923d959f6bc34ec61bc5ba7b673ed5478a3/Neos.Flow/Classes/Error/AbstractExceptionHandler.php#L338
i think then we should rather refactor the whole exception handling part and not introduce only a random wrapInPre option ...
I wonder if we can't scoop a good solution eg. from symfony or whoops or so.
good idea, i looked into Whoops, but they handle it not so nicely out of the box:
$message = <<<'MESSAGE'
<input>:1:7
|
1 | value {
| ^— column 7
No closing brace "}" matched this starting block. Encountered <EOF>.
MESSAGE;
throw new \Exception($message, 123);

@bwaidelich i just rebased this pr and its crazy that its already two years old ;D I understand your preservations, but think it's okay to fix this as proposed.