@@ -224,17 +224,36 @@ protected function execute(InputInterface $input, OutputInterface $output): int
224224 throw new \PHPStan \ShouldNotHappenException ();
225225 }
226226
227- $ analysisResult = $ application ->analyse (
228- $ files ,
229- $ onlyFiles ,
230- $ inceptionResult ->getStdOutput (),
231- $ inceptionResult ->getErrorOutput (),
232- $ inceptionResult ->isDefaultLevelUsed (),
233- $ debug ,
234- $ inceptionResult ->getProjectConfigFile (),
235- $ inceptionResult ->getProjectConfigArray (),
236- $ input
237- );
227+ try {
228+ $ analysisResult = $ application ->analyse (
229+ $ files ,
230+ $ onlyFiles ,
231+ $ inceptionResult ->getStdOutput (),
232+ $ inceptionResult ->getErrorOutput (),
233+ $ inceptionResult ->isDefaultLevelUsed (),
234+ $ debug ,
235+ $ inceptionResult ->getProjectConfigFile (),
236+ $ inceptionResult ->getProjectConfigArray (),
237+ $ input
238+ );
239+ } catch (\Throwable $ t ) {
240+ if ($ debug ) {
241+ $ inceptionResult ->getStdOutput ()->writeRaw (sprintf (
242+ 'Uncaught %s: %s in %s:%d ' ,
243+ get_class ($ t ),
244+ $ t ->getMessage (),
245+ $ t ->getFile (),
246+ $ t ->getLine ()
247+ ));
248+ $ inceptionResult ->getStdOutput ()->writeLineFormatted ('' );
249+ $ inceptionResult ->getStdOutput ()->writeRaw ($ t ->getTraceAsString ());
250+ $ inceptionResult ->getStdOutput ()->writeLineFormatted ('' );
251+
252+ return $ inceptionResult ->handleReturn (1 );
253+ }
254+
255+ throw $ t ;
256+ }
238257
239258 if ($ generateBaselineFile !== null ) {
240259 if (!$ analysisResult ->hasErrors ()) {
0 commit comments