14
14
use Symfony \Component \Console \Command \Command ;
15
15
use Symfony \Component \Console \Helper \Dumper ;
16
16
use Symfony \Component \Console \Style \SymfonyStyle ;
17
+ use Symfony \Component \ErrorHandler \Exception \FlattenException ;
17
18
use Symfony \Component \Messenger \Envelope ;
18
19
use Symfony \Component \Messenger \Stamp \ErrorDetailsStamp ;
19
20
use Symfony \Component \Messenger \Stamp \RedeliveryStamp ;
20
21
use Symfony \Component \Messenger \Stamp \SentToFailureTransportStamp ;
21
22
use Symfony \Component \Messenger \Stamp \TransportMessageIdStamp ;
22
23
use Symfony \Component \Messenger \Transport \Receiver \MessageCountAwareInterface ;
23
24
use Symfony \Component \Messenger \Transport \Receiver \ReceiverInterface ;
25
+ use Symfony \Component \VarDumper \Caster \Caster ;
26
+ use Symfony \Component \VarDumper \Caster \TraceStub ;
27
+ use Symfony \Component \VarDumper \Cloner \ClonerInterface ;
28
+ use Symfony \Component \VarDumper \Cloner \Stub ;
29
+ use Symfony \Component \VarDumper \Cloner \VarCloner ;
24
30
25
31
/**
26
32
* @author Ryan Weaver <[email protected] >
@@ -121,7 +127,7 @@ protected function displaySingleMessage(Envelope $envelope, SymfonyStyle $io)
121
127
122
128
if ($ io ->isVeryVerbose ()) {
123
129
$ io ->title ('Message: ' );
124
- $ dump = new Dumper ($ io );
130
+ $ dump = new Dumper ($ io, null , $ this -> createCloner () );
125
131
$ io ->writeln ($ dump ($ envelope ->getMessage ()));
126
132
$ io ->title ('Exception: ' );
127
133
$ flattenException = null ;
@@ -130,7 +136,7 @@ protected function displaySingleMessage(Envelope $envelope, SymfonyStyle $io)
130
136
} elseif (null !== $ lastRedeliveryStampWithException ) {
131
137
$ flattenException = $ lastRedeliveryStampWithException ->getFlattenException ();
132
138
}
133
- $ io ->writeln (null === $ flattenException ? '(no data) ' : $ flattenException -> getTraceAsString ( ));
139
+ $ io ->writeln (null === $ flattenException ? '(no data) ' : $ dump ( $ flattenException ));
134
140
} else {
135
141
$ io ->writeln (' Re-run command with <info>-vv</info> to see more message & error details. ' );
136
142
}
@@ -172,4 +178,26 @@ protected function getLastRedeliveryStampWithException(Envelope $envelope): ?Red
172
178
173
179
return null ;
174
180
}
181
+
182
+ private function createCloner (): ?ClonerInterface
183
+ {
184
+ if (!class_exists (VarCloner::class)) {
185
+ return null ;
186
+ }
187
+
188
+ $ cloner = new VarCloner ();
189
+ $ cloner ->addCasters ([FlattenException::class => function (FlattenException $ flattenException , array $ a , Stub $ stub ): array {
190
+ $ stub ->class = $ flattenException ->getClass ();
191
+
192
+ return [
193
+ Caster::PREFIX_VIRTUAL .'message ' => $ flattenException ->getMessage (),
194
+ Caster::PREFIX_VIRTUAL .'code ' => $ flattenException ->getCode (),
195
+ Caster::PREFIX_VIRTUAL .'file ' => $ flattenException ->getFile (),
196
+ Caster::PREFIX_VIRTUAL .'line ' => $ flattenException ->getLine (),
197
+ Caster::PREFIX_VIRTUAL .'trace ' => new TraceStub ($ flattenException ->getTrace ()),
198
+ ];
199
+ }]);
200
+
201
+ return $ cloner ;
202
+ }
175
203
}
0 commit comments