diff --git a/license.go b/license.go index 6d88995..1b992c6 100644 --- a/license.go +++ b/license.go @@ -2,6 +2,7 @@ package main import ( "embed" + "errors" "fmt" "path/filepath" "strings" @@ -13,6 +14,8 @@ const ( templatesPath = "templates" ) +var ErrInvalidLicense = errors.New("invalid license") + //go:embed templates/* var embedFS embed.FS @@ -35,13 +38,13 @@ type templateInfo struct { func generateLicense(name string) (string, error) { if name == "" { - return "", fmt.Errorf("empty license name") + return "", fmt.Errorf("empty license name: %w", ErrInvalidLicense) } name = strings.ToUpper(name) templateInfo, ok := templates[name] if !ok { - return "", fmt.Errorf("not support license %s", name) + return "", fmt.Errorf("not support license %s: %w", name, ErrInvalidLicense) } // Get correct path of license