diff --git a/src/WorkflowStub.php b/src/WorkflowStub.php index 476f468..93050b2 100644 --- a/src/WorkflowStub.php +++ b/src/WorkflowStub.php @@ -109,9 +109,7 @@ public static function await($condition): PromiseInterface 'result' => Y::serialize($result), ]); } catch (QueryException $exception) { - ++self::$context->index; - $deferred = new Deferred(); - return $deferred->promise(); + // already logged } } ++self::$context->index; @@ -142,9 +140,7 @@ public static function awaitWithTimeout($seconds, $condition): PromiseInterface 'result' => Y::serialize($result), ]); } catch (QueryException $exception) { - ++self::$context->index; - $deferred = new Deferred(); - return $deferred->promise(); + // already logged } } ++self::$context->index; @@ -197,9 +193,7 @@ public static function timer($seconds): PromiseInterface 'result' => Y::serialize($result), ]); } catch (QueryException $exception) { - ++self::$context->index; - $deferred = new Deferred(); - return $deferred->promise(); + // already logged } } ++self::$context->index; @@ -290,15 +284,16 @@ public function start(...$arguments): void $this->dispatch(); } - public function fail($throwable): void + public function fail($exception): void { try { $this->storedWorkflow->exceptions() ->create([ 'class' => $this->storedWorkflow->class, - 'exception' => Y::serialize($throwable), + 'exception' => Y::serialize($exception), ]); - } catch (\Throwable) { + } catch (QueryException) { + // already logged } $this->storedWorkflow->status->transitionTo(WorkflowFailedStatus::class); @@ -314,10 +309,8 @@ public function next($index, $now, $class, $result): void 'class' => $class, 'result' => Y::serialize($result), ]); - } catch (QueryException $exception) { - if (! str_contains($exception->getMessage(), 'Duplicate')) { - throw $exception; - } + } catch (QueryException) { + // already logged } $this->dispatch(); diff --git a/tests/Fixtures/TestWorkflow.php b/tests/Fixtures/TestWorkflow.php index c94af5a..5f87fcb 100644 --- a/tests/Fixtures/TestWorkflow.php +++ b/tests/Fixtures/TestWorkflow.php @@ -42,10 +42,10 @@ public function execute($shouldAssert = false) assert(! $this->canceled); } - $result = yield ActivityStub::make(TestActivity::class); - yield WorkflowStub::await(fn (): bool => $this->canceled); + $result = yield ActivityStub::make(TestActivity::class); + return 'workflow_' . $result . '_' . $otherResult; } } diff --git a/tests/Unit/WorkflowStubTest.php b/tests/Unit/WorkflowStubTest.php index 8873f01..b9fe254 100644 --- a/tests/Unit/WorkflowStubTest.php +++ b/tests/Unit/WorkflowStubTest.php @@ -62,6 +62,7 @@ public function testComplete(): void $this->assertSame('2022-01-01 00:00:00', WorkflowStub::now()->toDateTimeString()); $this->assertSame(WorkflowCompletedStatus::class, $workflow->status()); $this->assertSame('workflow', $workflow->output()); + $this->assertSame(1, $workflow->exceptions()->count()); $this->assertSame(1, $workflow->logs()->count()); } @@ -115,7 +116,7 @@ public function testAwaitWithTimeout(): void $this->assertSame(0, WorkflowStub::getContext()->index); - $promise = WorkflowStub::awaitWithTimeout('1 minute', static fn () => false); + $promise = WorkflowStub::awaitWithTimeout(60, static fn () => false); $this->assertSame(1, $workflow->logs()->count()); $this->assertSame(1, WorkflowStub::getContext()->index); pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy