File tree Expand file tree Collapse file tree 2 files changed +13
-11
lines changed
tests/Unit/Subscription/Engine Expand file tree Collapse file tree 2 files changed +13
-11
lines changed Original file line number Diff line number Diff line change 66
77use RuntimeException ;
88
9- use function array_map ;
10- use function implode ;
9+ use function count ;
1110use function sprintf ;
1211
1312final class ErrorDetected extends RuntimeException
@@ -16,15 +15,14 @@ final class ErrorDetected extends RuntimeException
1615 public function __construct (
1716 public readonly array $ errors ,
1817 ) {
19- $ sentences = array_map (
20- static fn (Error $ error ) => sprintf (
21- 'Subscription %s: %s ' ,
22- $ error ->subscriptionId ,
23- $ error ->message ,
18+ parent ::__construct (
19+ sprintf (
20+ '%s error(s) in subscription engine detected. First error is in "%s" subscription: %s ' ,
21+ count ($ errors ),
22+ $ errors [0 ]->subscriptionId ,
23+ $ errors [0 ]->message ,
2424 ),
25- $ errors ,
25+ previous: $ errors[ 0 ]-> throwable ,
2626 );
27-
28- parent ::__construct ("Error in subscription engine detected. \n" . implode ("\n" , $ sentences ));
2927 }
3028}
Original file line number Diff line number Diff line change @@ -24,8 +24,12 @@ public function testError(): void
2424
2525 self ::assertSame ($ errors , $ errorDetected ->errors );
2626 self ::assertSame (
27- " Error in subscription engine detected.\n Subscription id1: error1 \n Subscription id2: error2 " ,
27+ ' 2 error(s) in subscription engine detected. First error is in "id1" subscription: error1 ' ,
2828 $ errorDetected ->getMessage (),
2929 );
30+ self ::assertSame (
31+ $ errors [0 ]->throwable ,
32+ $ errorDetected ->getPrevious (),
33+ );
3034 }
3135}
You can’t perform that action at this time.
0 commit comments