Skip to content

Commit

Permalink
improve exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
juliangut committed Feb 2, 2022
1 parent 3f37c3d commit 772f223
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Driver/AbstractDriverFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,6 @@ protected function getAttributeDriver(array $paths): DriverInterface
*/
protected function getAnnotationDriver(array $paths): DriverInterface
{
throw new DriverException('Annotation metadata mapping driver is not supported.');
throw new DriverException('PHP class annotation metadata mapping driver is not supported.');
}
}
2 changes: 1 addition & 1 deletion src/Driver/Traits/JsonMappingTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ protected function loadMappingFile(string $mappingFile): array
);
} catch (JsonException $exception) {
throw new DriverException(
sprintf('JSON mapping file "%s" parsing error.', $mappingFile),
sprintf('JSON mapping file "%s" parsing error: %s.', $mappingFile, $exception->getMessage()),
0,
$exception,
);
Expand Down
2 changes: 2 additions & 0 deletions src/Driver/Traits/YamlMappingTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ protected function loadMappingFile(string $mappingFile): array
} catch (ParseException $exception) {
throw new DriverException(
sprintf('YAML mapping file "%s" parsing error: %s.', $mappingFile, rtrim($exception->getMessage())),
0,
$exception,
);
}
// @codeCoverageIgnoreEnd
Expand Down
2 changes: 1 addition & 1 deletion tests/Mapping/Driver/AbstractDriverFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ protected function setUp(): void
public function testAnnotationDriverNotImplemented(): void
{
$this->expectException(DriverException::class);
$this->expectExceptionMessage('Annotation metadata mapping driver is not supported.');
$this->expectExceptionMessage('PHP class annotation metadata mapping driver is not supported.');

(new EmptyDriverFactoryStub())->getDriver(['type' => DriverFactoryInterface::DRIVER_ANNOTATION, 'path' => []]);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Mapping/Driver/Traits/JsonMappingTraitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function testExtensions(): void
public function testLoadError(): void
{
$this->expectException(DriverException::class);
$this->expectExceptionMessageMatches('/^JSON mapping file ".+" parsing error\.$/');
$this->expectExceptionMessageMatches('/^JSON mapping file ".+" parsing error: Syntax error\.$/');

$this->mapping->loadMappingFile(__DIR__ . '/../../Files/files/invalid/invalid.json');
}
Expand Down

0 comments on commit 772f223

Please sign in to comment.