Skip to content

Commit dab59cc

Browse files
committed
Change exception message to be clearer
1 parent 159acc3 commit dab59cc

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

app/Helper/MWTimestampHelper.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ public static function getCarbonFromMWTimestamp(string $MWTimestamp): CarbonImmu
1818
try {
1919
$carbon = CarbonImmutable::createFromFormat(self::MWTimestampFormat, $MWTimestamp);
2020
} catch (InvalidFormatException $exception) {
21-
throw new InvalidFormatException('Unable to create Carbon object', 0, $exception);
21+
throw new InvalidFormatException('Unable to create Carbon object: invalid MW timestamp format', 0, $exception);
2222
}
2323

2424
if (!$carbon instanceof CarbonImmutable) {
25-
throw new InvalidFormatException('Unable to create Carbon object');
25+
throw new InvalidFormatException('Unable to create Carbon object: parser did not return CarbonImmutable');
2626
}
2727

2828
return $carbon;

tests/Helper/MWTimestampHelperTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public function testGetCarbonFromMWTimestamp() {
1919

2020
public function testGetCarbonFromMWTimestampWithInvalidTimestamp() {
2121
$this->expectException(InvalidFormatException::class);
22-
$this->expectExceptionMessage('Unable to create Carbon object');
22+
$this->expectExceptionMessage('Unable to create Carbon object: invalid MW timestamp format');
2323

2424
$invalidMwTimestamp = 'invalid_timestamp';
2525
MWTimestampHelper::getCarbonFromMWTimestamp($invalidMwTimestamp);

0 commit comments

Comments
 (0)