@@ -333,9 +333,14 @@ func (store *Store) RegisterPreprocessor(preprocessor templates.Preprocessor) {
333333
334334// Load loads all the templates from a store, performs filtering and returns
335335// the complete compiled templates for a nuclei execution configuration.
336- func (store * Store ) Load () {
337- store .templates = store .LoadTemplates (store .finalTemplates )
336+ func (store * Store ) Load () error {
337+ templates , err := store .LoadTemplates (store .finalTemplates )
338+ if err != nil {
339+ return err
340+ }
341+ store .templates = templates
338342 store .workflows = store .LoadWorkflows (store .finalWorkflows )
343+ return nil
339344}
340345
341346var templateIDPathMap map [string ]string
@@ -637,7 +642,7 @@ func isParsingError(store *Store, message string, template string, err error) bo
637642}
638643
639644// LoadTemplates takes a list of templates and returns paths for them
640- func (store * Store ) LoadTemplates (templatesList []string ) []* templates.Template {
645+ func (store * Store ) LoadTemplates (templatesList []string ) ( []* templates.Template , error ) {
641646 return store .LoadTemplatesWithTags (templatesList , nil )
642647}
643648
@@ -668,7 +673,8 @@ func (store *Store) LoadWorkflows(workflowsList []string) []*templates.Template
668673
669674// LoadTemplatesWithTags takes a list of templates and extra tags
670675// returning templates that match.
671- func (store * Store ) LoadTemplatesWithTags (templatesList , tags []string ) []* templates.Template {
676+ // Returns an error if dialers are not initialized for the given execution ID.
677+ func (store * Store ) LoadTemplatesWithTags (templatesList , tags []string ) ([]* templates.Template , error ) {
672678 defer store .saveMetadataIndexOnce ()
673679
674680 indexFilter := store .indexFilter
@@ -708,7 +714,7 @@ func (store *Store) LoadTemplatesWithTags(templatesList, tags []string) []*templ
708714
709715 wgLoadTemplates , errWg := syncutil .New (syncutil .WithSize (concurrency ))
710716 if errWg != nil {
711- panic ("could not create wait group" )
717+ return nil , fmt . Errorf ("could not create wait group: %w" , errWg )
712718 }
713719
714720 if typesOpts .ExecutionId == "" {
@@ -717,7 +723,7 @@ func (store *Store) LoadTemplatesWithTags(templatesList, tags []string) []*templ
717723
718724 dialers := protocolstate .GetDialersWithId (typesOpts .ExecutionId )
719725 if dialers == nil {
720- panic ("dialers with executionId " + typesOpts . ExecutionId + " not found" )
726+ return nil , fmt . Errorf ("dialers with executionId %s not found" , typesOpts . ExecutionId )
721727 }
722728
723729 for _ , templatePath := range includedTemplates {
@@ -852,7 +858,7 @@ func (store *Store) LoadTemplatesWithTags(templatesList, tags []string) []*templ
852858 return loadedTemplates .Slice [i ].Path < loadedTemplates .Slice [j ].Path
853859 })
854860
855- return loadedTemplates .Slice
861+ return loadedTemplates .Slice , nil
856862}
857863
858864// IsHTTPBasedProtocolUsed returns true if http/headless protocol is being used for
0 commit comments