Skip to content

Commit 72e3eaf

Browse files
committed
Merge pull request #62 from phpcr/catch_exceptions_when_rendering_list_items
Catch exceptions when rendering list items
2 parents 80d919d + c61caaa commit 72e3eaf

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ alpha-4
1313
### Bugs Fixes
1414

1515
- [args] 28 instances of bad InputArgument constructor fixed
16+
- [node] `node:list` Catch exceptions when rendering property rows (e.g. on invalid references)
1617

1718
alpha-3
1819
-------

features/phpcr_node_list.feature

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,11 @@ Feature: List properites and chidren of current nodeA
6868
"""
6969
jcr:uuid
7070
"""
71+
72+
Scenario: Catch exception on invalid reference
73+
Given I execute the "node:list /tests_general_base/numberPropertyNode/jcr:content" command
74+
Then the command should not fail
75+
And I should see the following:
76+
"""
77+
One or more weak reference targets have not been found
78+
"""

src/PHPCR/Shell/Console/Command/Phpcr/NodeListCommand.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,15 +153,22 @@ private function renderProperties($currentNode, $table, $spacers)
153153

154154
$i = 0;
155155
foreach ($properties as $name => $property) {
156-
$i++;
157-
if (isset($propertyNames[$name])) {
158-
unset($propertyNames[$name]);
156+
try {
157+
$i++;
158+
if (isset($propertyNames[$name])) {
159+
unset($propertyNames[$name]);
160+
}
161+
162+
$valueCell = $this->textHelper->truncate($this->formatter->formatValue($property), 55);
163+
164+
} catch (\Exception $e) {
165+
$valueCell = '<error>' . $e->getMessage() . '</error>';
159166
}
160167

161168
$table->addRow(array(
162169
'<property>' . implode('', $spacers). $name . '</property>',
163170
'<property-type>' . $this->formatter->getPropertyTypeName($property->getType()) . '</property-type>',
164-
$this->textHelper->truncate($this->formatter->formatValue($property), 55),
171+
$valueCell
165172
));
166173
}
167174

0 commit comments

Comments
 (0)