flow-development-collection icon indicating copy to clipboard operation
flow-development-collection copied to clipboard

BUGFIX: Web-Exception messages preserve whitespace (ASCII Art)

Open mhsdesign opened this issue 3 years ago • 5 comments

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

mhsdesign avatar Feb 06 '22 22:02 mhsdesign

hmm could potentially harm readability - what do you think? But is also easy to change later again when its not ideal.

mhsdesign avatar Feb 11 '22 14:02 mhsdesign

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)

bwaidelich avatar Mar 11 '22 09:03 bwaidelich

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 ...

mhsdesign avatar Mar 11 '22 13:03 mhsdesign

I wonder if we can't scoop a good solution eg. from symfony or whoops or so.

kitsunet avatar Mar 11 '22 13:03 kitsunet

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);

image

mhsdesign avatar Mar 14 '22 20:03 mhsdesign

@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.

mhsdesign avatar Feb 03 '24 10:02 mhsdesign