3
3
4
4
use ApiClients \Tools \OpenApiClientGenerator \Configuration ;
5
5
use ApiClients \Tools \OpenApiClientGenerator \Generator ;
6
+ use ApiClients \Tools \OpenApiClientGenerator \Output \Error ;
6
7
use EventSauce \ObjectHydrator \ObjectMapperUsingReflection ;
7
8
use Symfony \Component \Yaml \Yaml ;
8
9
@@ -14,20 +15,27 @@ use Symfony\Component\Yaml\Yaml;
14
15
})();
15
16
16
17
(function (string $ configuration ): void {
17
- /**
18
- * Create and boot up the application
19
- */
20
- exit ((function (string $ configurationFile ): int {
21
- $ configuration = (new ObjectMapperUsingReflection ())->hydrateObject (Configuration::class, Yaml::parseFile ($ configurationFile ));
22
- (new Generator (
23
- $ configuration ,
24
- dirname ($ configurationFile ) . DIRECTORY_SEPARATOR ,
25
- ))->generate (
26
- $ configuration ->namespace ->source . '\\' ,
27
- $ configuration ->namespace ->test . '\\' ,
28
- dirname ($ configurationFile ) . DIRECTORY_SEPARATOR ,
29
- );
18
+ $ exitCode = 1 ;
19
+ try {
20
+ /**
21
+ * Create and boot up the application
22
+ */
23
+ $ exitCode = (function (string $ configurationFile ): int {
24
+ $ configuration = (new ObjectMapperUsingReflection ())->hydrateObject (Configuration::class, Yaml::parseFile ($ configurationFile ));
25
+ (new Generator (
26
+ $ configuration ,
27
+ dirname ($ configurationFile ) . DIRECTORY_SEPARATOR ,
28
+ ))->generate (
29
+ $ configuration ->namespace ->source . '\\' ,
30
+ $ configuration ->namespace ->test . '\\' ,
31
+ dirname ($ configurationFile ) . DIRECTORY_SEPARATOR ,
32
+ );
30
33
31
- return 0 ;
32
- })($ configuration ));
34
+ return 0 ;
35
+ })($ configuration );
36
+ } catch (Throwable $ throwable ) {
37
+ Error::display ($ throwable );
38
+ } finally {
39
+ exit ($ exitCode );
40
+ }
33
41
})($ argv [1 ]);
0 commit comments