diff --git a/CHANGELOG.md b/CHANGELOG.md index 60384e68..c4d18f09 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,13 @@ The format is based on [Keep a Changelog], and this project adheres to [keep a changelog]: https://keepachangelog.com/en/1.0.0/ [semantic versioning]: https://semver.org/spec/v2.0.0.html +## [Unreleased] + +### Fixed + +- Fixed incorrect panic value when calling + `ProjectionConfigurer.DeliveryPolicy()` with a `nil` policy. + ## [0.13.0] - 2024-03-26 - **[BC]** Updated to Dogma v0.13.0 diff --git a/projection_test.go b/projection_test.go index 148e340d..3dab23d3 100644 --- a/projection_test.go +++ b/projection_test.go @@ -231,5 +231,16 @@ var _ = Describe("func FromProjection()", func() { ) }, ), + Entry( + "when the handler configures a nil delivery policy", + `delivery policy must not be nil`, + func(c dogma.ProjectionConfigurer) { + c.Identity("", projectionKey) + c.Routes( + dogma.HandlesEvent[fixtures.MessageA](), + ) + c.DeliveryPolicy(nil) + }, + ), ) }) diff --git a/projectionconfigurer.go b/projectionconfigurer.go index a943db28..f86ac37a 100644 --- a/projectionconfigurer.go +++ b/projectionconfigurer.go @@ -1,6 +1,9 @@ package configkit -import "github.com/dogmatiq/dogma" +import ( + "github.com/dogmatiq/configkit/internal/validation" + "github.com/dogmatiq/dogma" +) type projectionConfigurer struct { handlerConfigurer @@ -15,7 +18,7 @@ func (c *projectionConfigurer) Routes(routes ...dogma.ProjectionRoute) { func (c *projectionConfigurer) DeliveryPolicy(p dogma.ProjectionDeliveryPolicy) { if p == nil { - panic("delivery policy must not be nil") + validation.Panicf("delivery policy must not be nil") } c.deliveryPolicy = p