Aber ich möchte die gegebene Ausnahme aus dem fehlgeschlagenen Schritt behandeln. Und jetzt ist die Frage, wie? Darüber kann ich nichts finden.
Mein Code für die Pipeline sieht also so aus (z. B.):
Code: Select all
final readonly class CreateInboundPlanPipeline
{
public function __invoke(DataContainer $container, Closure $next): DataContainer
{
//Init Normalizer
$normalizer = new FBAInboundNormalizer();
//Do something with $container
$items = json_decode($container->__get('initialrequest')->input('items'));
$response = $normalizer->createInboundPlan($items, $container->__get('initialrequest'));
if($response['success']){
$extendContainer = $container;
$extendContainer->inboundplanid = $response["inboundPlanId"];
$extendContainer->currentOperationId = $response["operationId"];
}else{
throw new \Exception($response["message"]);
}
return $next($extendContainer);
}
}
public function handle(): void
{
$filledContainer = app(Pipeline::class)
->send($this->container)
->through([
CreateInboundPlanPipeline::class,
])
->then(function(){
//Action after Pipeline
//e.g. fill a model or smth
});
}
Ich habe die Funktion „handleException“ in der Pipeline gefunden, ist das der richtige Weg?
Würde so aussehen?
Code: Select all
$filledContainer = app(Pipeline::class)
->send($this->container)
->through([
CreateInboundPlanPipeline::class,
])
->then(function(){
//Action after Pipeline
//e.g. fill a model or smth
})
->handleException(function(){
//Handle Exception here
});