From ff87a5128bb0fea9d7075dc50c80751e86c2e7ea Mon Sep 17 00:00:00 2001 From: Cole Faust Date: Wed, 8 Mar 2023 11:51:49 -0800 Subject: [PATCH] Fix error messages not printing names Bug: 271424349 Test: Presubmits Change-Id: I8dd6ab7109c29bd8a03fd2f898eebe1a50a28914 --- context.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/context.go b/context.go index ddaea4d..9aa6ee5 100644 --- a/context.go +++ b/context.go @@ -512,7 +512,7 @@ type ModuleFactory func() (m Module, propertyStructs []interface{}) // to global variables must be synchronized. func (c *Context) RegisterModuleType(name string, factory ModuleFactory) { if _, present := c.moduleFactories[name]; present { - panic(errors.New("module type name is already registered")) + panic(fmt.Errorf("module type %q is already registered", name)) } c.moduleFactories[name] = factory } @@ -533,7 +533,7 @@ type SingletonFactory func() Singleton func (c *Context) RegisterSingletonType(name string, factory SingletonFactory) { for _, s := range c.singletonInfo { if s.name == name { - panic(errors.New("singleton name is already registered")) + panic(fmt.Errorf("singleton %q is already registered", name)) } } @@ -555,7 +555,7 @@ func (c *Context) RegisterSingletonType(name string, factory SingletonFactory) { func (c *Context) RegisterPreSingletonType(name string, factory SingletonFactory) { for _, s := range c.preSingletonInfo { if s.name == name { - panic(errors.New("presingleton name is already registered")) + panic(fmt.Errorf("presingleton %q is already registered", name)) } } @@ -608,7 +608,7 @@ func singletonTypeName(singleton Singleton) string { func (c *Context) RegisterTopDownMutator(name string, mutator TopDownMutator) MutatorHandle { for _, m := range c.mutatorInfo { if m.name == name && m.topDownMutator != nil { - panic(fmt.Errorf("mutator name %s is already registered", name)) + panic(fmt.Errorf("mutator %q is already registered", name)) } } @@ -635,7 +635,7 @@ func (c *Context) RegisterTopDownMutator(name string, mutator TopDownMutator) Mu func (c *Context) RegisterBottomUpMutator(name string, mutator BottomUpMutator) MutatorHandle { for _, m := range c.variantMutatorNames { if m == name { - panic(fmt.Errorf("mutator name %s is already registered", name)) + panic(fmt.Errorf("mutator %q is already registered", name)) } }