Replace error constant with an error type

dev
Ice3man543 2021-08-28 00:21:07 +05:30
parent f5ea35d45c
commit 30f6498fe2
2 changed files with 7 additions and 7 deletions

View File

@ -2,7 +2,6 @@ package loader
import (
"errors"
"strings"
"github.com/projectdiscovery/gologger"
"github.com/projectdiscovery/nuclei/v2/internal/severity"
@ -139,7 +138,7 @@ func areWorkflowOrTemplatesValid(store *Store, filteredTemplatePaths map[string]
}
func isParsingError(message string, template string, err error) bool {
if strings.Contains(err.Error(), templates.TemplateExecuterCreationErrorMessage) {
if err == templates.ErrCreateTemplateExecutor {
return false
}
if err == filter.ErrExcluded {

View File

@ -19,10 +19,11 @@ import (
"github.com/projectdiscovery/nuclei/v2/pkg/utils"
)
const TemplateExecuterCreationErrorMessage = "cannot create template executer"
var parsedTemplatesCache = cache.New()
var fieldErrorRegexp = regexp.MustCompile(`not found in`)
var (
ErrCreateTemplateExecutor = errors.New("cannot create template executer")
parsedTemplatesCache = cache.New()
fieldErrorRegexp = regexp.MustCompile(`not found in`)
)
// Parse parses a yaml request template file
//nolint:gocritic // this cannot be passed by pointer
@ -142,7 +143,7 @@ func Parse(filePath string, preprocessor Preprocessor, options protocols.Execute
template.TotalRequests += template.Executer.Requests()
}
if template.Executer == nil && template.CompiledWorkflow == nil {
return nil, errors.New(TemplateExecuterCreationErrorMessage)
return nil, ErrCreateTemplateExecutor
}
template.Path = filePath