1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2025-09-16 09:26:22 +02:00

feat: enhance error pattern matching with fallback to substring search

This commit is contained in:
Philip Germanov
2025-06-12 15:24:40 +03:00
parent 19032e754d
commit e8adc95f50

View File

@@ -71,12 +71,14 @@ func (w *logrusWriter) alwaysFlush() {
func checkKnownErrorPatterns(message string) string {
errors := GetStepErrors()
for _, stepError := range errors {
// First try regex matching
matched, err := regexp.MatchString(stepError.Pattern, message)
if err != nil {
// If regex is invalid, skip this pattern
continue
}
if matched {
// If regex is invalid, try simple substring matching
if strings.Contains(message, stepError.Pattern) {
return stepError.Message
}
} else if matched {
// Return the user-friendly error message
return stepError.Message
}