Skip to content

Commit db7e2b5

Browse files
author
Bl00D4NGEL
committed
fix: logic to throw first wrapped exception in messenger busses
1 parent 165f0d7 commit db7e2b5

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/Infrastructure/Messenger/CommandBus.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,12 @@ public function dispatch(Command $command): mixed
2525
return $this->handle($command);
2626
} catch (HandlerFailedException $e) {
2727
$exceptions = $e->getWrappedExceptions();
28-
throw $exceptions[0];
28+
$first = array_shift($exceptions);
29+
if ($first) {
30+
throw $first;
31+
}
32+
33+
throw $e;
2934
}
3035
}
3136
}

src/Infrastructure/Messenger/QueryBus.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,12 @@ public function dispatch(Query $query): mixed
2525
return $this->handle($query);
2626
} catch (HandlerFailedException $e) {
2727
$exceptions = $e->getWrappedExceptions();
28-
throw $exceptions[0];
28+
$first = array_shift($exceptions);
29+
if ($first) {
30+
throw $first;
31+
}
32+
33+
throw $e;
2934
}
3035
}
3136
}

0 commit comments

Comments
 (0)