Skip to content

Commit

Permalink
feat: show handler name for failures (#111)
Browse files Browse the repository at this point in the history
  • Loading branch information
kbond authored Nov 13, 2024
1 parent ac04193 commit 5a9cf9e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/History/HistoryListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,9 @@ private function createResults(Envelope $envelope, ?HandlerFailedException $exce
return new Results($results);
}

foreach ($exception->getWrappedExceptions() as $nested) {
foreach ($exception->getWrappedExceptions() as $handler => $nested) {
$results[] = [
'handler' => $handler,
'exception' => $nested::class,
'message' => $nested->getMessage(),
'data' => $this->normalizer->normalize($nested),
Expand Down
2 changes: 1 addition & 1 deletion src/History/Model/Result.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function isFailure(): bool

public function handler(): ?Type
{
if (!isset($this->data['handler'])) {
if (!isset($this->data['handler']) || !\is_string($this->data['handler'])) {
return null;
}

Expand Down
10 changes: 7 additions & 3 deletions templates/detail.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -130,17 +130,21 @@
<div class="card-header">
{% if result.isFailure %}
<svg fill="currentcolor" height="1em" width="1em" class="me-1 align-text-bottom text-danger" role="img" aria-label="Error:"><use xlink:href="#exclamation-triangle-fill"/></svg>
<abbr title="{{ result.failure }}"><code>{{ result.failure.shortName }}</code></abbr>
{% else %}
<svg fill="currentcolor" height="1em" width="1em" class="me-1 align-text-bottom text-success" role="img" aria-label="Success:"><use xlink:href="#check-circle-fill"/></svg>
{% endif %}
{% set handler = result.handler|default %}
{% if handler %}
<code>
<abbr title="{{ result.handler }}">{{ result.handler.shortName }}</abbr>{% if result.handler.description %}::{{ result.handler.description }}(){% endif %}
<abbr title="{{ handler }}">{{ handler.shortName }}</abbr>{% if handler.description %}::{{ handler.description }}(){% endif %}
</code>
Results
{% else %}
<small class="text-secondary"><em>Unknown Handler</em></small>
{% endif %}
</div>
{% if result.isFailure %}
<div class="alert card-alert alert-danger mb-0">
<abbr title="{{ result.failure }}"><code>{{ result.failure.shortName }}</code></abbr>:
{{ result.failure.description }}
</div>
{% endif %}
Expand Down

0 comments on commit 5a9cf9e

Please sign in to comment.