Skip to content

Commit

Permalink
feat: Improve AdditionalPropertiesException message to include bag cl…
Browse files Browse the repository at this point in the history
…ass name
  • Loading branch information
dshafik committed Feb 4, 2025
1 parent 785e242 commit d7f0f33
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Bag/Exceptions/AdditionalPropertiesException.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ public function __construct(string $bagClass, Collection $extraProperties)
);
});

parent::__construct('Additional properties found: '.$extraProperties->implode(', '));
parent::__construct(sprintf('Additional properties found for bag (%s): %s', $bagClass, $extraProperties->implode(', ')));
}
}
2 changes: 1 addition & 1 deletion tests/Feature/BagTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@
$value = TestBag::from(name: 'Davey Shafik', age: 40, email: '[email protected]', extra: 'extra', foo: 'bar');
})->throws(
AdditionalPropertiesException::class,
'Additional properties found: extra, foo'
'Additional properties found for bag (Tests\Fixtures\Values\TestBag): extra, foo'
);

test('it accepts ordered params', function () {
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Pipelines/Pipes/ExtraParametersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@

$pipe = new ExtraParameters();
$pipe($input);
})->throws(AdditionalPropertiesException::class, 'Additional properties found: test');
})->throws(AdditionalPropertiesException::class, 'Additional properties found for bag (Tests\Fixtures\Values\TestBag): test');


test('it errors on non variadic with extra positional parameters', function () {
Expand Down

0 comments on commit d7f0f33

Please sign in to comment.