Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
LandonTClipp committed Oct 19, 2023
1 parent 3c3cd9d commit bb23a0c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pkg/template/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
_ "embed"

"github.com/vektra/mockery/v2/pkg/registry"
"github.com/vektra/mockery/v2/pkg/stackerr"
)

// Template is the Moq template. It is capable of generating the Moq
Expand All @@ -25,7 +26,12 @@ var styleTemplates = map[string]string{

// New returns a new instance of Template.
func New(style string) (Template, error) {
tmpl, err := template.New("moq").Funcs(templateFuncs).Parse(styleTemplates[style])
templateString, styleExists := styleTemplates[style]
if !styleExists {
return Template{}, stackerr.NewStackErrf(nil, "style %s does not exist", style)
}

tmpl, err := template.New("moq").Funcs(templateFuncs).Parse(templateString)
if err != nil {
return Template{}, err
}
Expand Down

0 comments on commit bb23a0c

Please sign in to comment.