Handling Failures
Handling Failures and Exceptions in Sagas and Process Managers
Uncovered Business Scenarios
Let the Exception propagate
final readonly class OrderController
{
public function __construct(private CommandBus $commandBus) {}
public function placeOrder(Request $request): Response
{
$orderId = $request->get('orderId');
$customerId = $request->get('customerId');
$items = $request->get('items');
try {
$this->commandBus->send(PlaceOrder::create($orderId, $customerId, $items));
}catch (InvalidOrder $exception) {
// Customize Response based on the Exception details
return new Response($exception->getMessage(), 422);
}
return new Response('Order placed');
}
}Handling failures in the Message Handler
Recoverable Synchronous Errors

Recoverable Asynchronous Errors

Unrecoverable Asynchronous Errors

Customizing Global Error Handling
Customizing Error Handling on Message Handler Level
Last updated
Was this helpful?