43
43
use ArtARTs36 \MergeRequestLinter \Presentation \Console \Command \InfoCommand ;
44
44
use ArtARTs36 \MergeRequestLinter \Presentation \Console \Command \InstallCommand ;
45
45
use ArtARTs36 \MergeRequestLinter \Presentation \Console \Command \LintCommand ;
46
+ use ArtARTs36 \MergeRequestLinter \Presentation \Console \Exceptions \ApplicationNotCreatedException ;
46
47
use ArtARTs36 \MergeRequestLinter \Presentation \Console \Output \ConsoleLogger ;
47
48
use ArtARTs36 \MergeRequestLinter \Shared \Events \CallbackListener ;
48
49
use ArtARTs36 \MergeRequestLinter \Shared \Events \EventDispatcher ;
@@ -65,6 +66,9 @@ public function __construct(
65
66
//
66
67
}
67
68
69
+ /**
70
+ * @throws ApplicationNotCreatedException
71
+ */
68
72
public function create (OutputInterface $ output ): Application
69
73
{
70
74
$ clock = $ this ->registerClock ();
@@ -125,7 +129,7 @@ public function create(OutputInterface $output): Application
125
129
}
126
130
127
131
/**
128
- * @throws \Exception
132
+ * @throws ApplicationNotCreatedException
129
133
*/
130
134
private function registerClock (): Clock
131
135
{
@@ -135,12 +139,10 @@ private function registerClock(): Clock
135
139
$ tzId = $ this ->environment ->getString ('MR_LINTER_TIMEZONE ' );
136
140
137
141
try {
138
- $ tz = new \ DateTimeZone (trim ($ tzId ));
139
- } catch (\Throwable ) {
140
- throw new \ Exception ( sprintf ( ' TimeZone "%s" invalid ' , $ tzId ) );
142
+ $ clock = LocalClock:: on (trim ($ tzId ));
143
+ } catch (\Throwable $ e ) {
144
+ throw new ApplicationNotCreatedException ( $ e -> getMessage (), previous: $ e );
141
145
}
142
-
143
- $ clock = new LocalClock ($ tz );
144
146
}
145
147
146
148
$ this ->container ->set (ClockInterface::class, $ clock );
@@ -234,7 +236,7 @@ private function createLogger(OutputInterface $output, MetricManager $metricMana
234
236
{
235
237
$ loggers = [
236
238
MetricableLogger::create ($ metricManager ),
237
- new ConsoleLogger ($ output ),
239
+ new ConsoleLogger ($ output, $ this -> container -> get (ClockInterface::class) ),
238
240
];
239
241
240
242
$ compositeLogger = new CompositeLogger ($ loggers );
0 commit comments