@@ -66,23 +66,33 @@ class Cli extends Console\Application
66
66
/**
67
67
* @param string $name the application name
68
68
* @param string $version the application version
69
+ * @SuppressWarnings(PHPMD.ExitExpression)
69
70
*/
70
71
public function __construct ($ name = 'UNKNOWN ' , $ version = 'UNKNOWN ' )
71
72
{
72
- $ configuration = require BP . '/setup/config/application.config.php ' ;
73
- $ bootstrapApplication = new Application ();
74
- $ application = $ bootstrapApplication ->bootstrap ($ configuration );
75
- $ this ->serviceManager = $ application ->getServiceManager ();
76
-
77
- $ this ->assertCompilerPreparation ();
78
- $ this ->initObjectManager ();
79
- $ this ->assertGenerationPermissions ();
80
-
81
- if ($ version == 'UNKNOWN ' ) {
82
- $ directoryList = new DirectoryList (BP );
83
- $ composerJsonFinder = new ComposerJsonFinder ($ directoryList );
84
- $ productMetadata = new ProductMetadata ($ composerJsonFinder );
85
- $ version = $ productMetadata ->getVersion ();
73
+ try {
74
+ $ configuration = require BP . '/setup/config/application.config.php ' ;
75
+ $ bootstrapApplication = new Application ();
76
+ $ application = $ bootstrapApplication ->bootstrap ($ configuration );
77
+ $ this ->serviceManager = $ application ->getServiceManager ();
78
+
79
+ $ this ->assertCompilerPreparation ();
80
+ $ this ->initObjectManager ();
81
+ $ this ->assertGenerationPermissions ();
82
+
83
+ if ($ version == 'UNKNOWN ' ) {
84
+ $ directoryList = new DirectoryList (BP );
85
+ $ composerJsonFinder = new ComposerJsonFinder ($ directoryList );
86
+ $ productMetadata = new ProductMetadata ($ composerJsonFinder );
87
+ $ version = $ productMetadata ->getVersion ();
88
+ }
89
+ } catch (\Exception $ exception ) {
90
+ $ output = new Console \Output \ConsoleOutput ();
91
+ $ output ->writeln (
92
+ '<error> ' . $ exception ->getMessage () . '</error> '
93
+ );
94
+
95
+ exit (static ::RETURN_FAILURE );
86
96
}
87
97
88
98
parent ::__construct ($ name , $ version );
0 commit comments