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

feat(log): improve error message formatting by combining message and error details

This commit is contained in:
Philip Germanov
2025-07-29 15:22:35 +03:00
parent 70bb1525da
commit 420505e93d

View File

@@ -117,8 +117,18 @@ func (s *Splunk) prepareTelemetry(telemetryData telemetry.Data) MonitoringData {
if fatalErrorDetail := log.GetFatalErrorDetail(); fatalErrorDetail != nil {
var errorDetail map[string]any
if err := json.Unmarshal(fatalErrorDetail, &errorDetail); err == nil {
var parts []string
if messageVal, exists := errorDetail["message"]; exists && messageVal != nil {
parts = append(parts, fmt.Sprintf("%v", messageVal))
}
if errorVal, exists := errorDetail["error"]; exists && errorVal != nil {
errorMessage = fmt.Sprintf("%v", errorVal)
parts = append(parts, fmt.Sprintf("%v", errorVal))
}
if len(parts) > 0 {
errorMessage = strings.Join(parts, " ")
}
}
}