2024-03-13 02:27:15 +01:00
|
|
|
package templates
|
|
|
|
|
|
|
|
|
|
import (
|
2025-08-20 05:28:23 +05:30
|
|
|
"fmt"
|
2024-03-13 02:27:15 +01:00
|
|
|
|
2025-08-20 05:28:23 +05:30
|
|
|
"github.com/projectdiscovery/utils/errkit"
|
2024-03-13 02:27:15 +01:00
|
|
|
)
|
2025-08-20 05:28:23 +05:30
|
|
|
|
|
|
|
|
// Helper functions for template errors with formatting
|
|
|
|
|
func ErrMandatoryFieldMissingFmt(field string) error {
|
|
|
|
|
return errkit.New(fmt.Sprintf("mandatory '%s' field is missing", field)).Build()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func ErrInvalidField(field, format string) error {
|
|
|
|
|
return errkit.New(fmt.Sprintf("invalid field format for '%s' (allowed format is %s)", field, format)).Build()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func ErrWarningFieldMissing(field string) error {
|
|
|
|
|
return errkit.New(fmt.Sprintf("field '%s' is missing", field)).Build()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func ErrCouldNotLoadTemplate(path, reason string) error {
|
|
|
|
|
return errkit.New(fmt.Sprintf("Could not load template %s: %s", path, reason)).Build()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func ErrLoadedWithWarnings(path, warning string) error {
|
|
|
|
|
return errkit.New(fmt.Sprintf("Loaded template %s: with syntax warning : %s", path, warning)).Build()
|
|
|
|
|
}
|