You've already forked sap-jenkins-library
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:
@@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user