Skip to content

Commit 6e80158

Browse files
Standardizing thrown exceptions
1 parent 6a19b12 commit 6e80158

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

lib/internal/Magento/Framework/Stdlib/DateTime/Timezone.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,7 @@ public function convertConfigTimeToUtc($date, $format = 'Y-m-d H:i:s')
354354
* @param string $timezone
355355
* @param string $locale
356356
* @return string
357+
* @throws LocalizedException
357358
*/
358359
private function appendTimeIfNeeded($date, $includeTime, $timezone, $locale)
359360
{
@@ -366,6 +367,16 @@ private function appendTimeIfNeeded($date, $includeTime, $timezone, $locale)
366367
new \DateTimeZone($timezone)
367368
);
368369
$convertedDate = $formatterWithoutHour->parse($date);
370+
371+
if (!$convertedDate) {
372+
throw new LocalizedException(
373+
new Phrase(
374+
'Could not append time to DateTime'
375+
)
376+
);
377+
378+
}
379+
369380
$formatterWithHour = new \IntlDateFormatter(
370381
$locale,
371382
\IntlDateFormatter::SHORT,

0 commit comments

Comments
 (0)